Hallo Forum,
meine Anwendung benutzt eine fxml-Datei zur Beschreibung der GUI. Erzeuge ich ein 'Runnable JAR file', so meckert das Programm beim Start die Zeile mit dem load-Aufruf an mit der Meldung 'Location not set'. Das sieht dann so aus:
Der Start der Anwendung:
Offenbar wird die GUI Beschreibung nicht fest 'eincompiliert'. Sie wird wohl irgendwo abgelegt sein müssen. Ich hab schon eine Menge probiert, aber leider hatte ich bisher keinen Erfolg. Habt Ihr noch Tipps für mich??
VG Holger
meine Anwendung benutzt eine fxml-Datei zur Beschreibung der GUI. Erzeuge ich ein 'Runnable JAR file', so meckert das Programm beim Start die Zeile mit dem load-Aufruf an mit der Meldung 'Location not set'. Das sieht dann so aus:
Code:
C:\Users\holger\Documents\BMCheck>java -jar bmcheck.jar
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
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(Unknown Source)
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 bmcheck.BMCheck.start(BMCheck.java:32)
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.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more
Exception running application bmcheck.BMCheck
C:\Users\holger\Documents\BMCheck>
Code:
public class BMCheck extends Application {
private static TauchgangPool tauchgangPool = new TauchgangPool();
private static Stage primaryStage;
private static BMCheck mainApp;
// private String fxmlGUI = "../viewcontroller/BMCheckGUI.fxml";
private BMCheckGUIController guiController;
private String windowTitle = "BM Check";
@Override
public void start(Stage primaryStage) throws Exception {
BMCheck.mainApp = this;
BMCheck.primaryStage = primaryStage;
FXMLLoader guiLoader = new FXMLLoader();
guiLoader.setLocation(BMCheck.class.getResource("../viewcontroller/BMCheckGUI.fxml"));
Parent root = guiLoader.load();
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.setTitle(windowTitle);
Double screenWidth = Toolkit.getDefaultToolkit().getScreenSize().getWidth();
Double screenHeight = Toolkit.getDefaultToolkit().getScreenSize().getHeight();
primaryStage.setWidth(screenWidth * 2.0 / 3.0);
primaryStage.setHeight(screenHeight * 3.0 / 4.0);
primaryStage.setX(50);
guiController = guiLoader.getController();
primaryStage.setOnCloseRequest((windowEvent) -> {
guiController.beendenMitNachfragen();
windowEvent.consume();
});
primaryStage.show();
}
public static void main(String[] args) {
launch(BMCheck.class, args);
}
public static Stage getPrimaryStage() {
return primaryStage;
}
public static TauchgangPool getTauchgangPool() {
return tauchgangPool;
}
public static BMCheck getMainApp() {
return mainApp;
}
}
VG Holger