2

I habe a big problem with my JAR File. I work with IntelliJ and hav following Filestructure of my project...

Filestructure

and got this error when I want to start the compiled JAR File:

Error

The thing is, wehn I start the program in IntelliJ it works fine... The following code I use to get the resource out of the folder:

URL loginScreen = getClass().getResource("/fxml/loginScreen.fxml");
        AnchorPane login = FXMLLoader.load(loginScreen);

even that doesn't work:

URL loginScreen = getClass().getClassLoader().getResource("loginScreen.fxml");
        AnchorPane login = FXMLLoader.load(loginScreen);

When I want to test the Path and do

System.out.println(getClass().getResource("/fxml/loginScreen.fxml")); 
System.out.println(getClass().getClassLoader().getResource("fxml/loginScreen.fxml"));

I get the full path. Now i compile it to JAR and I get 'null'.

After a lot of google search and testing any of this links doesn't work:

JavaFX "Location is required." even though it is in the same package

this.getClass().getClassLoader().getResource("...") and NullPointerException

.

What I doing wrong? Sorry for my language ;)

Undex
  • 33
  • 1
  • 5

0 Answers0