How to create a fat jar for my JavaFX program?

Matthias Bläsing mblaesing at doppel-helix.eu
Mon Jul 20 17:30:53 UTC 2020


Hi,

Am Montag, den 20.07.2020, 19:25 +0200 schrieb Davide Perini:
> Unfortunantly so few dependencies supports Java Modules this day, so
> fat JAR is the only way I can do it.

no it is not. There are seveal ways how to bundle native libraries.
jpackage is one way, fat jars are another. And for fat jars of course
you can extract native libraries at runtime (JNA does exactly that).
What is difficult is the handling of native dependencies. If you know
what you are doing you can manually load native libraries in the right
order.

The alternative is to distribute a ZIP file and setup the paths prior
to loading libraries. Changing the java.library.path takes some
reflection, but it is possible to do at runtime.

The javafx jars from maven central hold the native libraries.

Matthias



More information about the openjfx-dev mailing list