简体   繁体   中英

JavaFx Location is not set when application is compiled to a jar file

My program runs fine when I run it on eclipse but when I package it in a jar file, I get this error when I run it.

java.lang.IllegalStateException: Location is not set.
        at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
        at javafx.fxml.FXMLLoader.load(Unknown Source)
        at controller.MainController.initAnalyzer(MainController.java:144)
        at applicationMain.Main.start(Main.java:32)
        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 Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(Unknown Source)
        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)
        at java.lang.Thread.run(Unknown Source)

I am certain that the path is correct. I have tried to change the path but nothing seems to work. I've also checked answers here and from other websites but nothing seems to solve my problem. It just does not make sense that my other FXML files under the same folder loaded well but not these three.

在此处输入图片说明

I think of the two following ways:

  1. Make sure you set the path correctly. Anyway you should show us the folder system and how you set the path. Don't forget that the path starts from the current package, not the root of the project.
  2. Clean and Build your project and run it again. It often somehow helps me to solve lots of issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM