I'm facing the same problem!
I was adding an ImageView to a Button and add image path to that ImageView in FXML file using SceneBuilder. This was working fine when I run it through Eclipse IDE but not when run as jar file.
After removing the ImageView from the Button, it started to work fine even when run as jar.
But, now I'm stuck with the same problem in different scenario!
I'm using 3 FXML files to build up the entire window.
- MainWindow (Border Pane) -- this contains a Menu bar and Tool bar added to the top position of the border pane.
- CenterWindow (Anchor Pane)
- ButtomWindow (Anchor Pane)
In the controller of the MainWindow I'm trying to add the CenterWindow and ButtomWindow which are in different fxml files.
But, NullPointerException
occurs in the MainWindow Controller at the line where I'm trying to load the fxml file. It says Location is required in the exception.
I have extraced the jar file and checked, the fxml files are there inside the jar.
Can someone please help.
Package Structure:
com.example.app -- contains Main.java which has main() method
com.example.app.controller -- MainWindowController.java, CenterWindowController.java, ButtomWindowController.java
com.example.app.view -- MainWindow.fxml, CenterWindow.fxml, ButtomWindow
In Main.java I'm loading MainWindow.fxml which loads fine. Then in MainWindowController.java I'm trying to load CenterWindow.fxml & ButtomWindow which gives exception.
Exception log:
javafx.fxml.LoadException:
file:/C:/Users/a27490989/Documents/NetBeansProjects/AirbusDS/dist/AirbusDS.jar!/
ds/airbus/simulator/view/MainWindow.fxml
at javafx.fxml.FXMLLoader.constructLoadException(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at ds.airbus.simulator.Main.start(Main.java:22)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$51/747183799.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$44/584634336.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/94326726.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$45/501263526.run(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$141(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/96639997.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Location is required.
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
at javafx.fxml.FXMLLoader.load(Unknown Source)
at ds.airbus.simulator.controller.MainWindowController.initOutputView(MainWindowController.java:214)
at ds.airbus.simulator.controller.MainWindowController.initialize(MainWindowController.java:204)
... 23 more