Hi guys,

I've made an application in JavaFX and I do want to export it into a runnable jar.
When I run it from Eclipse or Netbeans, it works well.
But when I run it from windows as an executable jar I get this error for my layout.

Exception in Application start method
Exception in thread "main" 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:497)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
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$152(LauncherImpl.java:182)
        at com.sun.javafx.application.LauncherImpl$$Lambda$2/1338668845.run(Unknown Source)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Location is not set.
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2438)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2413)
        at application.MainApp.initRootLayout(MainApp.java:47)
        at application.MainApp.start(MainApp.java:38)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherImpl.java:863)
        at com.sun.javafx.application.LauncherImpl$$Lambda$52/2117128939.run(Unknown Source)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java:326)
        at com.sun.javafx.application.PlatformImpl$$Lambda$48/1721003345.run(Unknown Source)
        at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
        at com.sun.javafx.application.PlatformImpl$$Lambda$50/268638582.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
        at com.sun.javafx.application.PlatformImpl$$Lambda$49/42105627.run(Unknown Source)
        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$145(WinApplication.java:101)
        at com.sun.glass.ui.win.WinApplication$$Lambda$38/622073264.run(Unknown Source)
        ... 1 more

My code looks like this on the 47'th line loader.setLocation(getClass().getResource("../application/view/RootLayout.fxml"));

private void initRootLayout() {
    try {
        // Load root layout from fxml file.
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(getClass().getResource("../application/view/RootLayout.fxml"));
        rootLayout = (BorderPane) loader.load();
        // Show the scene containing the root layout
        Scene scene = new Scene(rootLayout);
        //scene.getStylesheets().add("application/application.css");
        primaryStage.setScene(scene);
        primaryStage.show();

    } catch(IOException e) {
        e.printStackTrace();
    }
}
This question has already been answered. Start a new discussion instead.