What are the current pains / issues with deploying JavaFX desktop apps multi platform?
I am looking into the red headed stepchild of the Java desktop applications world, JavaFX, but struggling to get a clear answer on the issues are that make multiplatform deployments a pain.
Anyone better versed able to shed light on the matter?
22 Replies
⌛ This post has been reserved for your question.
Hey @jorr_dann96! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./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.
JavaFX is not part of the JDK.
Because of this, the application needs to include native code which is platform dependent.
You can create one bundle that includes the code for all platforms but that would be big.
Also since JavaFX relies on JPMS modules, you shouldn't create a single "fat" JAR for your application.
The best way to package JavaFX applications is jlink/jpackage.
With jlink/jpackage, you have one archive (With jlink, it's a folder or zip file, with jpackage it's an executable i.e. deb/msi (or exe)/dmg file) that includes both a minimal JRE, the application and libraries i.e. everything necessary to run the application
but you will need to provide one per platform and I think you can't cross compile
So how does this compare to other GUI solutions?
Because to me, this seems like an "issue" that could easily be "coded away" with a DX friendly build tool of some sort
I ask as, ngl, actually using JavaFX is actually really nice.
The FXML format, and how it works directly with controllers via the @FXML annotation is actually really nice / clean imho.
Just seems bizzare it was dropped
Like, when I use swing? I get frustrated quick. When I use JavaFX, it has never not felt "Nice" to use.
Swing: Still part of the JDK, can be packaged however you want to
SWT: pretty lightweight, no additional external (runtime) dependencies except SWT, can be packaged however you want to
So what could potentially be a tool to make as a developer who wants to use JavaFX, to make the multi platform process less of a headache?
and the deploying part is just that JavaFX is a bit more work for the dev to set up
It wasn't dropped, it was just moved outside of the JDK
It's not only developed by Oracle (but Oracle is still doing a significant part of the development)
CI/CD pipelines and jlink/jpackage
If you have a normal JavaFX setup with modules using Maven, you can just run
mvn javafx:jlink and you get a working bundle for your platform (though that's a directory).
You can set that up for Windows, Linux and MacOS in your CI/CD pipeline
If you use modules properly, it isn't that much of a headache IMOMaybe a tool to remove the CI/CD pipeline step?
As tbh, most modern GUI frameworks do just have a one and done if I am not mistaken?
you might want to specify a launcher in order to make sure it can be set easily - but that should just be a few lines of configuration
Do you know what CI/CD is?
I am aware of CI/CD thank you.
Most CI/CD frameworks are platform dependent so you'd need to build at least once per platform
Then how would you imagine skipping it with some "tool"?
That "tool" would be virtual machines
Ah I was not entirely aware, I was under the impression that most frameworks like electron / tauri had that sorted by standard as part of the framework itself.
Maybe thats ignorance on my part
i.e. the multiple builds
I think these would still either need a runtime installed before (e.g. node in the case of JS frameworks I guess) or you have one binary/build per OS
You can do the approach with one package for all OSes with a single build - but that results in a bigger package with lots of unnecessary stuff in it
Maybe a tool that has the CI/CD for building the binary/build for each OS, without you having to set it up yourself every time?
Like a template maker sort of deal? I'm just spitballing.
It just seems... not great DX wise
Set it up once and then copy it?
it isn't that complicated and you'd probably want a CI/CD setup for every serious project anyway
Was thinking more for developers who first use JavaFX.
I cant imagine having the teething pains of their first deployment would be a great expereince haha
They can just run
mvn javafx:jlink and get a bundle for their OS
if they follow the recommended setupfor their OS
yes
when you are first using JavaFX, you typically don't care about other OSes
I hope you do not take this the wrong way, as I mean it completely objectively, but speak for yourself.
Not meant to be an insult, but an objective pointing out as. Well tbh... hi
and having a standard CI/CD setup seems to be questionable since there are many CI/CD systems out there - and you need a git repo etc
That I do agree with
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.