When running the app inside IntelliJ, everything works fine.
When building artifacts, the reference to *.fxml files are not found and return when calling getClass().getResources("/path/to/fxml/file.fxml")
Executing *.jar or *.exe throws a NullPointerException: Location is not set.
How can this be resolved?
If this doesnt work, inside your project in IntelliJ, right-click on your resource directory and select Mark Directory As.. -> Mark as Resource Root
Make sure your paths are in the following structure:
"/subdirectories/file.fxml"
So if your fxml-files are located at: resources/layout/main.fxml:
"/layout/main.fxml"
So / is your resource directory
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.