0

I'm trying to export my application which I have recently created. It works in Eclipse perfectly without any errors but once it's been exported it cannot be launched, and whenever I try to run it through CMD it shows these lines of errors

    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(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: java.lang.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown So
urce)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(
Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: Location is not set.
        at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
        at javafx.fxml.FXMLLoader.load(Unknown Source)
        at vp.dict.main.MainApp.initLayouts(MainApp.java:61)
        at vp.dict.main.MainApp.start(MainApp.java:53)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162
(Unknown Source)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(Unknown
 Source)
        at com.sun.javafx.application.PlatformImpl.lambda$null$173(Unknown Sourc
e)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(Unknown S
ource)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$148(Unknown Source)
        ... 1 more

The chunk of my code

public void start(Stage window) throws IOException {
        this.window = window;
        this.window.setTitle("EN/CZ Dictionary 2017");

        **line 53 initLayouts();
    }

    public void initLayouts() throws IOException{

        window.getIcons().add(new Image("/images/icon.png"));
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(getClass().getResource("../view/rootLayout.fxml"));
        **line 61 BorderPane rootLayout = (BorderPane)loader.load();

        Scene scene = new Scene(rootLayout);
        window.setScene(scene);
        RootController controller = loader.getController();
        controller.setMainApp(this);

        window.show();

        // Load ContentController
        loader = new FXMLLoader();
        loader.setLocation(getClass().getResource("../view/contentLayout.fxml"));
        AnchorPane ap = (AnchorPane)loader.load();

        rootLayout.setCenter(ap);
        ContentController contentController= loader.getController();
        contentController.setMainApp(this);
        controller.setContentController(contentController);

        // Try to load last opened person file.
        File file = getDataFilePath();
        if (file != null) {
            loadDataFromFile(file);
        }   
    }
halfer
  • 19,471
  • 17
  • 87
  • 173
Jiri
  • 103
  • 8
  • Please post the entire stack trace (as [formatted text](http://meta.stackoverflow.com/questions/251361/how-do-i-format-my-code-blocks), not as an image) and the code that is causing the exception (also as formatted text) in your question. – James_D Feb 20 '17 at 13:18
  • Thanks for your comment. I've updated my post. – Jiri Feb 20 '17 at 14:01
  • I've solved the problem. – Jiri Feb 20 '17 at 15:14

0 Answers0