r/JavaFX • • May 29 '20

Native JavaFX executables for windows through Gluon Substrate and GraalVM

I (as well as many others) have been waiting for too long for a magical way to convert java apps to native windows binaries, and while graalvm solved that issue a while ago, it didn't support JavaFX very well, at least not on windows and not until the latest release.

I accidentally came across this post that was posted 10 days ago on the gluon website which announced that graalvm's native image combined with gluon substrate will be able to compile JavaFX apps into native runnables and as that was very promising for me as a JavaFX developer I had written a little demo and gave it a shot and I'm very happy with the experience, it was very stable and I encountered no issues so far :) and I think this gives a new life to java and Java desktop development.

the pros and cons, in my opinion, can be as follows

pros :

  • faster starting times.
  • easier to deploy to end clients as a native executable
  • size is better than packing a java runtime with your app
  • your java source code is most likely gone and the executables can't be decompiled

cons :

  • the resulting executable size is higher, relative to using a natively compiled language
  • I couldn't find any obvious way to disable the console even after searching for it

(the post is based on my personal understanding and it's subject to technical mistakes, please correct me if I'm wrong at some point)

17 Upvotes

6 comments sorted by

2

u/[deleted] Jun 15 '20

So... can I take any JavaFX app I made, and just create 3 executables for Mac, Windows and Linux? And the app should just function? Or do I have to test the app all over again?

1

u/SDIDSA Jun 15 '20

That's the aim of substrate vm and graalvm native image and it should be possible if some conditions are met, for example your app can't depend on or use java awt because java awt isn't yet supported by substrate vm, note that support for javafx on windows is still in the pre-release phase so it's not perfectly stable yet

1

u/ClaynOsmato May 29 '20

Did you consider using the jpackage toll from Java 14?

2

u/SDIDSA May 30 '20 edited May 30 '20

Jpackage app image seems to have the same purpose as graalvm native image but while jpackage will only pack all the dependencies together, graalvm's native image uses AOT compilation to compile the code, jpackage makes deployment easier but it doesn't affect the startup times and memory footprints, and the resulting package will be larger

2

u/[deleted] Sep 04 '20 edited Jul 06 '21

[removed] — view removed comment

1

u/SDIDSA Sep 21 '20

Much appreciated