Allan Juan
Allan Juan

Reputation: 2558

How to include assets in app deployed with JLink?

I have a JavaFX Maven project that has the following folder structure:

+ -- src/

+ -- -- java/
+ -- -- -- com/pkg/
+ -- -- -- -- App.java

+ -- -- resources/
+ -- -- -- com/pkg/
+ -- -- -- -- fxml/app.fxml
+ -- -- -- -- css/app.css
+ -- -- -- -- img/img.png

When I need to load an FXML file, for example, I do:

URL url = getClass().getResource("/com/pkg/fxml/app.fxml");

Everything was fun and games until I tried to ship my app with JLink. I ran JLink maven goal and it created an executable in /target/image/bin/java. I can run it, but it soon raises LoadException because it couldn't find some FXML file. Indeed, I can't find any .fxml, .css or .png file inside target/, because resources/ is not there.

So what am I doing wrong here - the file structure, or the build? And how can I fix this?

Upvotes: 0

Views: 268

Answers (0)

Related Questions