Linked Questions

Popular Questions

After upgrading IntelliJ java and javaFx to 11 and gradle to 5.1.1. When creating new Image I need to state the full directory like so:

new Image("file:src/main/java/sample/image.png");

Where before I could simply do:

new Image("image.png")

Any idea why the project isn't recognizing my packages correctly for new Image("image.png") it is giving me this error, but before the updates it was working fine:

java.lang.IllegalArgumentException: Invalid URL or resource not found

What I want to accomplish is making the images and fxml visible when executing the jar. I am creating a jar file and when I specific the path like this for the fxml or image:

FXMLLoader loader = new FXMLLoader();
loader.setLocation(new URL("file:src/main/java/sample/login.fxml"));
Pane root = loader.load(); 

When I run the jar I get:

Caused by: java.io.FileNotFoundException: src\main\java\sample\login.fxml (The system cannot find the path specified)

How can I make it so that when I pack it as a jar it can find the files, also why before the update I could simply write: new Image("image.png") and now I need to write: new Image("file:src/main/java/sample/image.png")? Any help would be appreciate!

Related Questions