r/java • • Jan 02 '25

How Java's Executable Assembly Jars Work

https://mill-build.org/blog/5-executable-jars.html
64 Upvotes

42 comments sorted by

View all comments

Show parent comment

1

u/larsga Jan 03 '25

That means you do not need to make an uber jar with all the other dependencies.

If you don't your release is also not a single file, thus harder to distribute, and the risk of different environments having different versions of dependencies is higher. Adding a new dependency also becomes harder.

2

u/agentoutlier Jan 03 '25

I encourage you to explore what an uber jar and jlink application is and how this is all just packaging.

With what I’m recommending your packaging could be a docker image I rather superior packaging format over several alternatives.

Even with the actual true one file of exe (which is not uber jar but graalvm native) you now have the permutations of platforms but worse than docker as you have os and arch. (Docker its just arch and the registry makes it easy for users to get the right one instead of some list of zip/exe downloads on a release page).

An uber image is probably the worse packaging as the JDK is not designed for it. It breaks encapsulation and does not include the JDK.