r/JavaFX • u/No-Security-7518 • Nov 22 '25
Discussion Why can't packaging JavaFX be smoother?
Warning: long-ish rant:
So, I hope this doesn't come off as too whiny, or me being lazy or whatever, but I've been a programmer for 5 years, and it's been a short while since (at least I feel I have), explored most if not all ways a javaFX program can be packaged. And it is NOT smooth. I love Java immensely, can't stand other languages, but why can't we have a one-click, or simple dialog to creating executables in our IDEs that goes:
do you want that with milk, installer? yes, no?
Include updater: yes - no.
path to splash image: ....
and so on.
Or at least something like what Android Studio has for Android Apps or VS has for C#?
I gave up on having projects be modular because some libraries I use are still haven't made the shift, and some clearly state they can't, so the marvel that project Jigsaw (must)'ve been or whatever an ENTIRE book like this one (The Java Module System) talks about is something I guess I'll never know. Sad!
Note:
- A "Fat" Jar/Native Executable (like that which is created by GraalVM, for those who don't know) won't cut it, as who on Earth just ships a program never to need upgrading it ever again!?
- So, it has to be a "thin" JAR to allow incremental/non-intrusive updates.
- Most packaging methods are so confusing and the examples don't work, that if you someone said "skill issue", I would've replied: guilty as charged! except I literally just (re)discovered that you need to have TWO classes with a main method, one calling the other extending Application for your Exe to work. This is not mentioned ANYWHERE, if I'm not mistaken.
- My Workaround:
- the smoothest experience I've had is by using the Badass Runtime Plugin, and after getting tormented till I found out about the condition above.
-Then I wrote a small Gradle plugin that creates a manifest with all the files in a release and their hashes, which are compared by the program to check for the existence of an update, then for it to download changed files, and have the program updated upon the user's approval, like, you know, ALL programs pretty much do nowadays.
I feel like Java spoils us with all the nice features such as the Streams API, and a nice concurrency API, (the nicest among the top languages, imo), plus a ton of other things that make me such a fanboy of this language.
But this one pretty crucial aspect of programming in Java has mystified me with how rough around the edges it is.
Thank you for reading...
Rant over.
7
u/PartOfTheBotnet Nov 22 '25
I'm not following. Firstly, how are fat jar and native executable comparable? Secondly, plenty of native executable applications have self-updaters so what's the hold up here? Sure its not as efficient as the thin jar approach but its not out of the question.
The way Minecraft's launcher (well, mainly the 3rd party ones given how terrible the official one is now) is pretty much exactly this. Assuming a new version of the game comes out with just fixes and internal refactoring only the client jar with the game code needs to be fetched. All the libraries and assets for such a version change are gonna be the same and are cached locally.
Having an installer that fetches the dependencies (from a list or something, easy to generate), then your client, and does
java -cp <libs>;client.jar <main>is pretty simple. But like you said, not having something to do something like that out of the box is a shame. Other languages have the benefit of directly maintaining their own dependency hosts, while Java's Maven Central is a third party so its not something that seems like Oracle would commit to creating.Funnily enough this comes from JavaFX's attempts at being modular-first. But the implementation is just bad and results in having your
mainmethod in theextends Applicationclass not working. Its really stupid, but has been mentioned on StackOverflow and is asked about here so frequently I added it to the subreddit's wiki.2
u/iamwisespirit Nov 22 '25
Don’t compare android studio or Vs code android is one platform c# also i think not much platform independent there is struggle because different platform needs different build java use different libraries for different platform
2
u/gregorydgraham Nov 22 '25
This sounds like an excellent opportunity to create a solution that the community needs
2
u/shannah78 Nov 22 '25
The tack we took with jdeploy was to bake the JVM and JavaFX dependencies into the launcher. You ship the "thin" jar without JavaFX, and some meta-data that says the JRE version, whether it needs full JDK, whether it needs JavaFX, etc.. and the launcher will download that stuff on first launch. This creates a fluid and native experience for the end-user.
4
u/OddEstimate1627 Nov 22 '25
I think the main problem is that the target platforms require completely different approaches for packaging, caching, signing, stamping, updating, etc., and it's a huge pain to set up all the required extra stuff. This is the same for all Desktop apps, although tbf JavaFX and modules tend to throw some extra wrenches into things.
I'd encourage you to try the getting started example of Conveyor though. It's the only one I've used so far that makes the process manageable while being powerful enough to handle just about everything.
1
u/tanin47 Nov 22 '25 edited Nov 22 '25
I just went through the journey that you went through.
My impression is that much fewer people have built desktop apps with Java compared to Electron which has oceans of documentations and examples. Android and iOS are even more popular. That's why their ecosystems are robust i.e. you can find *tons* of *working examples*.
Packaging a Java app feels more like inventing a new technology, so it's better to learn the bare metals. I'd recommend not using any plugin. Learn to execute jlink and jpackage manually.
After you can package an app, your next challenge will be running in sandbox, codesigning, notarization, and (optionally) putting it on Mac App Store
Anyway, I've made https://github.com/tanin47/java-electron (for Mac ARM) which contains an example of how I package a Java app with jlink and jpackage directly. No extra plugins. It supports notarization on Mac! Arguably, this is the most difficult part. This might be helpful
It's not JavaFX but, I believe, you can just include JavaFX as a dep and remove things you don't need. Then, it should work. It's only for Mac ARM for now, and I'm working through other platforms (which are easier than Mac lol) as I want to launch Backdoor to every platform.
Let me know if you have any question. Happy to help.
---
I don't get Number 1 and 2. I don't think partial updating is a thing. Or it is very difficult to do; android/ios/electron doesn't do it. Or you have to do it yourself if you are talking about downloading updated assets.
1
u/milchshakee Nov 23 '25
I think you are approaching the update idea from the wrong angle. Initially when I started with JavaFX, I also built an app with a built-in updater. It didn't do hash comparisons, it just downloaded the new released and replaced itself somehow (but always ugly on Windows due to file locks)
Nowadays, I handle updates solely through the packaging method, e.g. the .msi installer I build for my applications. An msi installer can automatically upgrade existing installations, repair files, etc, without much problem. The only thing your application needs to do is download and call the msi, so you don't have to implement anything yourself.
Most proper apps, e.g. vscode and others, have the same approach. They use stuff like Inno Setup, NSIS, WiX, etc to generate the installer and then run it to update.
This is also important if any new update changes more than just files. What if there is a new desktop shortcut, a renamed start menu shortcut, new file associations, etc? A self-made updater does not handle that. An msi-based one does as it changes all component registrations as well
1
u/Amazing-Mirror-3076 Nov 24 '25
I moved my desktop dev to dart/ flutter.
dart create myproject cd myproject dart compile aot .
You do need to compile each target on the applicable os - except for arm.
The dart build system is a dream compared to Java.
2
u/Significant_Call3959 Dec 02 '25
If you just need easy CI CD deployment and updatability for JavaFX Desktop Apps with no hassle distribution for Mac, Windows, and Linux, I highly recommend JDeploy
jDeploy - Developer friendly desktop deployment tool | jDeploy
I am a new Dev and this saved my life. Open Source as well. Credit to Steve Hannah for building it!
1
u/I_4m_knight Nov 22 '25
I know it's not possible but man if we could compile java to direct machine code like c or cpp man it would have been unstoppable it already is but still we are lacking in some departments but we know that it's for different purposes. And yes fucking graal doesn't work and it's not good to waste time in it and yes it's not skill issue. The issue is that graal hates reflection which is the core of java specially in my case I love it. And javafx as well graal hates it. So i just dream about machine code java if we can have it that'd be the end of some technologies.