Parent root = FXMLLoader.load(new URL(MainApp.class.getResource(<path to 
fxml>).toExternalForm()));

Should do it fine…make sure your file path is accurately cased.

On 15 Jun 2019, at 10:41, Helmut Leininger 
<h.leinin...@gmx.at<mailto: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
<h_leininger.vcf>



CONFIDENTIALITY NOTICE This message and any included attachments are from 
Cerner Corporation and are intended only for the addressee. The information 
contained in this message is confidential and may constitute inside or 
non-public information under international, federal, or state securities laws. 
Unauthorized forwarding, printing, copying, distribution, or use of such 
information is strictly prohibited and may be unlawful. If you are not the 
addressee, please promptly delete this message and notify the sender of the 
delivery error by e-mail or you may call Cerner's corporate offices in Kansas 
City, Missouri, U.S.A at (+1) (816)221-1024. Cerner Limited, Registered in 
England no 2519305, Registered Office 37 North Wharf Road, London W2 1AF.

Reply via email to