JavaRush /Java Blog /Random-TL /Pagbuo ng proyekto ng JavaFX sa isang jar file.

Pagbuo ng proyekto ng JavaFX sa isang jar file.

Nai-publish sa grupo
Mangyaring tulungan akong malaman ito. Gumawa ako ng isang proyekto sa JavaFX at inilunsad ito mula sa IDE nang walang mga error. Gumawa ako ng jar file para sa proyektong ito, noong inilunsad ko ang jar file mula sa IDE nakakuha ako ng error: /usr/lib/jvm/java-8-oracle/bin/java -Dfile.encoding=UTF-8 -jar /home/artem/IdeaProjects/Address_book/out/artifacts/Address_book_jar/Address_book.jar Exception in Application start method java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389) at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767) Caused by: java.lang.RuntimeException: Exception in Application start method at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182) at java.lang.Thread.run(Thread.java:745) Caused by: javafx.fxml.LoadException: file:/home/artem/IdeaProjects/Address_book/out/artifacts/Address_book_jar/Address_book.jar!/fxml/main.fxml at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409) at Main.start(Main.java:15) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method) at com.sun.glass.ui.gtk.GtkApplication.lambda$null$49(GtkApplication.java:139) ... 1 more Caused by: java.lang.IllegalStateException: Location is not set. at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409) at controllers.MainController.initialize(MainController.java:199) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548) ... 12 more Exception running application Main i.e. nagrereklamo tungkol sa fxmlLoader.load(). Pangunahing klase: import controllers.MainController; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage primaryStage) throws Exception { FXMLLoader fxmlLoader = new FXMLLoader(); fxmlLoader.setLocation(getClass().getResource("/fxml/main.fxml")); Parent fxmlMain = fxmlLoader.load(); MainController mainController = fxmlLoader.getController(); mainController.setMainStage(primaryStage); primaryStage.setTitle("Адресная книга"); primaryStage.setMinHeight(315); primaryStage.setMinWidth(290); Scene scene = new Scene(fxmlMain, 315, 290); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } } ControllerPangunahing klase: @Override public void initialize(URL location, ResourceBundle resources) { columnFIO.setCellValueFactory(new PropertyValueFactory ("fio")); columnPhone.setCellValueFactory(new PropertyValueFactory ("phone")); try { fxmlLoader.setLocation(getClass().getResource("../fxml/edit.fxml")); fxmlEdit = fxmlLoader.load(); editDialogController = fxmlLoader.getController(); } catch (IOException e) { e.printStackTrace(); } initListeners(); fillData(); }
Mga komento
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION