JavaFX applications built to target Java 8 - How t

2019-03-02 12:27发布

I recently learned about JavaFX not being included in Java 11, and have a question about how this will work.

Right now, I maintain an application that targets Java 8, uses mostly Swing but some JavaFX, and has a non-developer user base. Some of those users are on older operating systems, so I'd like to continue targeting Java 8.

However, Java 11 comes out next month, and I'm concerned that some of the users on newer operating systems will upgrade to Java 11, and the JavaFX components of the application will cease to work.

So what is the best path forward if you wish to continue targeting Java 8, but have JavaFX work for those who install JRE 11? I see several options, none of which are perfect:

  • Require installing JavaFX separately. If so, I'll need to know which edition - most likely the OS-specific SDK from https://gluonhq.com/products/javafx/? Not ideal since it's another install, but I already have instructions for installing Java for those who don't have it.
  • Bundle a JRE and JavaFX, and have startup scripts that force the use of that JRE. Not ideal because the download size would drastically increase, and it would require separate downloads per OS, but I've made distributions that bundle a JRE before.
  • Fall back on Swing instead of JavaFX if Java 11+ is detected. I could potentially do this, since my application started out as Swing and only a fraction has migrated, but it's also not attractive since the newer, JavaFX-specific functionality I've added would be lost.
  • Try including the JavaFX runtime as a .jar file and loading it on the classpath manually, perhaps only if Java 11+ is detected?

I'm curious what your thoughts are, and if there's a better option I've overlooked. I didn't anticipate JavaFX being removed from the JRE someday when I adopted it!

2条回答
手持菜刀,她持情操
2楼-- · 2019-03-02 12:35

tl;dr

Follow these tutorials found at the new home for JavaFX after having been spun out of Oracle to Gluon.

There is no JRE for Java 11, only the JDK.

If you want to continue targeting Java 8 in your development, you will need to require your users to install one of the last versions of JRE.

But for several reasons, it makes sense to make the jump to Java 11. There have been many big improvements in JavaFX (as I understand, not my world). Java 8 is end-of-life soon for free-of-cost updates (likely, unless the community steps up to make updates). Java 11 is a LTS version. The modularization of Java, along with the new linking/packaging tools, enable you to bundle a smaller size subset of the JDK with your app. Your users will no longer be burdened with the download-install-update chores for a JRE.

JRE no more… long live JDK

Oracle no longer intends for end-users to be installing a JRE or a JDK. The technology for Java Applets in a browser and Java Web Start app delivery are both being phased out, leaving the end-user with no need for a JRE. Java-based apps are expected to bundle their own Java implementation. The only folks consciously installing a JDK will be developers & server-side sysadmins.

Important:

Learn about:

Here is a flowchart diagram that may help you finding and deciding amongst the various vendors providing a Java 11 implementation.

Flowchart diagram to aid in finding and choosing an implementation of Java 11 from various vendors.

查看更多
The star\"
3楼-- · 2019-03-02 12:56

To my opinion the days where you asked your users to install Java on their client machines is over. The better solution is to create an operating system dependent installer which bundles everything with the application. I am also wondering if the size of such a bundle still really matters. A single video downloaded from YouTube is probably much bigger. Instead, by bundling you save yourself a lot of headaches.

查看更多
登录 后发表回答