r/JavaFX • u/Fuzzy-System8568 • Jun 05 '26
Help How to build a self contained app with Maven?
This is honestly driving me nuts. There does not seem to be solid documentation anywhere.
I dont want someone to point me at something like Jdeploy. Or some other super duper all in one solution. I am learning. I care as much about the process as I do the final product. If people cannot learn the core concepts of building JavaFX apps that are self contained, all these "all in one" solutions will slowly lose contributors as the core knowledge is lost imho... I.e. im wanting to avoid "bus factor" by learning how to do it myself from scratch.
How do you build a self contained package / where are all the good resources / documentation that contain information on building self contained packages. Somebody help me please, as i feel im going nuts 😅
5
u/ebykka Jun 05 '26
I do for my application - check the profile "package"
https://github.com/bykka/dynamoit/blob/master/pom.xml
3
u/sedj601 Jun 05 '26
I think there is really good information on StackOverflow.
2
u/Fuzzy-System8568 Jun 05 '26
I thank those who have provided some answers.
But i will be bold and propose something. I have only been given half answers / other people's setups... or vague answers of "im sure on stack overflow"...
Real talk everyone? I think we are lacking fundemental documentation for one of the most important parts of an Desktop App Framework...
I would highly propose someone take their solution and write up some propper documentation about the process.
Or, falling that, ill do it (once ive fully figured it out haha)
1
u/Fuzzy-System8568 Jun 08 '26
So I have to ask then, what is everyone actually using then? I.e. rather than fully from scratch what are all of you actually using to package up your JavaFX apps?
3
u/NaveenB2004 Jun 06 '26 edited Jun 06 '26
Assuming you're on the latest JDK (26),
Use the Jlink tool that comes with the JDK installation.
https://docs.oracle.com/en/java/javase/26/docs/specs/man/jlink.html
You can use it with the Maven plugin 'maven-jlink-plugin'.
https://maven.apache.org/plugins/maven-jlink-plugin/
https://central.sonatype.com/artifact/org.apache.maven.plugins/maven-jlink-plugin
And use JavaFX from Maven plugins (I guess the SDK will also work with a proper environment, but I have never tested it).
https://central.sonatype.com/namespace/org.openjfx
By using Jlink, you will be able to build cross-platform bundles from one platform with different JDKs (one for each, win, mac, linux). I'll be able to attach some examples, soon...
Sample application (start from pom.xml for docs):
https://github.com/NaveenB2004/SelfContained-JFX
1
u/No-Security-7518 Jun 05 '26
It took me YEARS to get to a super streamlined way to package a Javafx program (using Gradle). I hope this doesn't bother you, but please, switch to Gradle, Maven will get stupidly slow with builds as the program matures, with Gradle, not so much.
Anyway, here's the plugin:
https://badass-runtime-plugin.beryx.org/releases/latest/
2
u/BanaTibor Jun 05 '26
For maven you need the shade plugin. https://maven.apache.org/plugins/maven-shade-plugin/
1
u/827527 Jun 05 '26
I use this works well. https://github.com/javapackager/JavaPackager
1
u/koppor Jun 07 '26
If it's tiny, try JBang. If it's large, try gradle. I had (kind of) success with both.