Hello.
this problem occurs only when NOT using NetBeans (becouse NB may use this normal file sctructure, without jars)
here is part of my main class, start method
//load FXMLs
FXMLLoader primaryLoader = new FXMLLoader();
URL primaryLocation = getClass().getResource("PrimaryStage.fxml");
primaryLoader.setLocation(primaryLocation);
Parent root = (Parent) primaryLoader.load();
Scene primaryScene = new Scene(root);
FXMLLoader secondaryLoader = new FXMLLoader();
URL secondaryLocation = getClass().getResource("SecondaryStage.fxml");
secondaryLoader.setLocation(secondaryLocation);
System.out.println("sec loader = " +secondaryLoader.toString()
+"\n sec loc from loader = "+secondaryLoader.getLocation()
+"\n sec loc url = " + secondaryLocation
+"\n pri loc url = " + primaryLocation);
Parent secondaryRoot = (Parent) secondaryLoader.load();
Scene secondaryScene = new Scene(secondaryRoot);
and the thing is the 1st url (primaryLocation) is loaded properly, and the secondLocation aint.
those 2 files are both in the same jar, same folder (packege) as main class.
the outcome looks like this
sec loader = javafx.fxml.FXMLLoader@5bde2a20
sec loc from loader = null
sec loc url = null
pri loc url = jar:file:/C:/test_workspace/NetBeans/MZlike/dist/MoreAdvStuff.jar!/moreadvstuff/PrimaryStage.fxml
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.javafx.main.Main.launchApp(Main.java:486)
at com.javafx.main.Main.main(Main.java:638)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at com.sun.javafx.application.LauncherImpl.access$000(Unknown Source)
at com.sun.javafx.application.LauncherImpl$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: Location is not set.
at javafx.fxml.FXMLLoader.load(Unknown Source)
at moreadvstuff.MoreAdvStuff.start(MoreAdvStuff.java:55)
at com.sun.javafx.application.LauncherImpl$5.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl$4.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl$3.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(Unknown Source)
at com.sun.glass.ui.win.WinApplication$2$1.run(Unknown Source)
... 1 more
where 55 line is
Parent secondaryRoot = (Parent) secondaryLoader.load();
any ideas how to fix it? loading the file manually from the jar may be a way, but its a workaround, not a solution
Edited by: Radosław on 2012-05-17 07:55