#How can I reduce the size of fat jar?
33 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @copper rapids! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Are you building the same JAR for Windows, Linux and MacOS?
The biggest part of JavaFX are the native parts which are different for these
So instead of including them all in a single fat JAR, you can create three JARs
no, the jar I'm building is only suitable for linux
unfortunately, I don't know what you're talking about(
actually 8MB is very small for a JavaFX application
I wanted to know whether you are using FXML files
no, I'm not using FXML files
javafx-controls is around 2.5MB and javafx-graphics is around 4.9MB
both of them are needed
You could ofc try some shrinking/dead code elimination but I think that would do almost nothing with JavaFX
Also JavaFX doesn't even support fat JARs
like I don't even think native-image would reduce much
So no I don't think you can get much smaller with JavaFX
One thing you could do is not distributing any JAR file but a jlink image - that would be bigger but your users wouldn't need to install a JDK/JRE
(that's the recommended way to package JavaFX applications as fat JARs aren't supported as mentioned earlier)
but I kinda made a working fat jar with javafx
if that's not possible, should I close this ticket?
yes you can kinda get it working but classpath deployments are not supported
I mean there are things you could try like an obfuscation/shrinking tool
that looks for things that aren't needed and removes them
but idk how well that would work
you could also try using native-image with the native-image agent but that would probably be quite a bit of work and might result in a bigger executable (though one that doesn't need Java to run)
For that specifically - I'd close the post if you have no more questions about it - but you don't have to close it if you don't want to
are there any such tools for java 24? I've only found tools for 17
ok, thanks, I'll try again later, sorry I can't right now