4

So with Java 11 getting rid of JavaFX I will have to switch to OpenJFX however I am still unsure on how to allow people to just download my application and have it work right out of the box. Right now I have people using it on Mac, Linux and Windows and I would love to continue this support without asking them to install or download anything.
Is there any way I can ship OpenJFX alongside my jar and especially allow it to be cross-platform compatible?
Any help is appreciated

Jalau
  • 303
  • 1
  • 2
  • 11
  • 4
    To ship the JavaFX modules with your application you can build a custom runtime image using the [jlink](https://docs.oracle.com/en/java/javase/11/tools/jlink.html) tool. For native packaging, you'll have to wait for [jpackager](https://docs.oracle.com/en/java/javase/11/tools/jlink.html) or use some other third party tool. Here's another, at least similar, question: https://stackoverflow.com/questions/52584519/does-javafx-after-removing-it-from-jdk-cross-platform – Slaw Oct 24 '18 at 22:10
  • @Slaw Is there a way for me to load the libraries from a folder on the host system? So I can tell the people to download the binaries for their system and then download my cross platform jar? – Jalau Oct 25 '18 at 09:46
  • It is possible for the user to install an JRE, to which the modules an native libraries of JFX are added. This JRE would be able to execute your platform independent application. But - it is not the recommended way. – tobain Oct 30 '18 at 20:32
  • Instead you should create a custom JRE which only includes your application modules and their dependencies (Standard Library and JFX modules). JDK 11 provides the jlink tool to do this. A downside of jlink is the fact that it does create executables, installers, or packages. It simply provides a JDK with all needed modules and a startup script to tell this JRE to run your main class. Previous JDK versions came with the javapackager tool which could do this, but it was removed from JDK 11. Instead we might have to wait for JDK 12 to include the jpackager tool, which serves as the replacement. – tobain Oct 30 '18 at 20:46
  • 1
    I have bumped my head many many times in the past half year that I allowed a JavaFX dependency to creep into my project. I know it's not a nice answer, but I can only give one advise: Scrap JavaFX and go back to Swing. It just works everywhere. Unless you have crazy resources to deploy custom binaries to all platforms, just stick to Swing which has zero work. – 0__ Aug 14 '19 at 11:09

0 Answers0