I have put all my JavaFX code into a executable JAR-file. Everything is inside there.
When I compile it with Eclipse IDE, it works, but when I try to execute the JAR-file, I get an error.
Caused by: javafx.fxml.LoadException:
file:/home/asus/program/JUSBPlotter/JUSBPlotter-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/se/danielmartensson/fxml/front.fxml
When I have this Java code
Parent root = FXMLLoader.load(getClass().getResource("/se/danielmartensson/fxml/front.fxml"));
There is nothing wrong with the FXML file.
fx:controller="se.danielmartensson.controller.Front"
Also I get errors when I try to display a picture in JavaFX.
Caused by: java.io.FileNotFoundException: file:/home/asus/program/JUSBPlotter/JUSBPlotter-0.0.1-SNAPSHOT-jar-with-dependencies.jar!/se/danielmartensson/pictures/computer.png (No such file or directory)
When I have this Java code:
FileInputStream picture1 = new FileInputStream(getClass().getResource("/se/danielmartensson/pictures/computer.png").getFile());
Question: How can I tell Java the correct file path in JAR-file?