When I google ‘JavaFX location is not set’, I see quite a few responses and solutions.
Gj On Sat, 15 Jun 2019 at 11:42, Helmut Leininger <h.leinin...@gmx.at> wrote: > Hi, > > I do not know if this is the correct place to ask. > > I am running Windows10, netbeans 11,openjdk 12, javafx 12. > > I am developping a modular javafx application, using Ant (i.e. no Maven, > no Gradle). > > I have several modules (Mainmodule, Tools, UI). In the UI module is the > package MainWindow, where the MainApp, all controllers and all > FXML-files reside. > In the MainController, when a certain Button is clicked, I open another > Window (of the same package). > > The code sniplet: > > FXMLLoader fxmlLoader =3D new > FXMLLoader(getClass().getResource("fenster1.fxml")); > System.out.println("Location: " + fxmlLoader.getLocation()); > Parent rootFenster1 =3D (Parent) fxmlLoader.load (); > Fenster1 =3D new Stage(); > ... > > > This works well when run from the IDE. When run from the comand line, I > get the following errors whenn trying to open the second window: > > dist>C:\OpenSourceTools\jdk-12/bin/java --module-path=3D%JAVAFX_HOME%\lib > --add-modules=3Djavafx.controls,javafx.fxml > -cp UI.jar MainWindow.MainApp > Location: null > java.lang.IllegalStateException: Location is not set. > at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2459) > at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:2435 > > > What has to be done that the FXMLLoader can find the FXML file also when > run from the comand line? > > Regards > > Helmut >