4

Many work environments continue to stay on JRE8 -- I'm a little confused on how to proceed with developing for the latest versions of Java. I compile JavaFX applications with Java SE 8 using NetBeans 9. Is there a way for me to start distributing via JDK 9, 10, and 11+ but still keep it compatible with all the JRE8 environments?

Or once I compile via JDK11, will it only be compatible when or if an environment upgrades their runtime? Or can I distribute a completely separate jar that runs without the need for a JRE and start today (even if they stay on JRE 8)?

trilogy
  • 1,738
  • 15
  • 31
  • 1
    If you don’t create modular .jar files, then you really don’t have to do anything differently for the application to run in Java 8, aside from making sure your compiler targets Java 8. – VGR Oct 10 '18 at 17:13
  • Problem with that is the JavaFX libraries don't exist in 11, so you would have to add those dependencies in there right? – trilogy Oct 12 '18 at 17:00
  • Follow [these tutorials](https://openjfx.io/openjfx-docs/) found at the [new home for JavaFX](https://openjfx.io) after having [been spun out](https://gluonhq.com/gluon-and-javafx/) of Oracle to [Gluon](https://gluonhq.com). – Basil Bourque Feb 18 '19 at 00:59
  • Similar: [*Bundle JavaFX app with openjdk 11 + runtime*](https://stackoverflow.com/q/52969440/642706). – Basil Bourque Feb 18 '19 at 01:01

1 Answers1

2

There is a break between Java 8, and the modular Javas 9+. Though the module system has support for combined non-modular and modular code, JavaFX becomes OpenJFX, and I would not rely on there being one code base for long.

Also mind that modular means you can deliver your application with JRE parts as a small standalone executable.

So develop in Java 11+, possibly "convert" the sources to java 8 with a small tool written yourself. Restrict the usage of var and other short-cuts. (Maybe develop in java 8 and convert to Java 9+?).

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
Joop Eggen
  • 107,315
  • 7
  • 83
  • 138
  • If I compile using JDK 11+, I have to add the JavaFX dependencies (OpenJFX). If I want it to continue to run for 8, they are not needed. So what you're saying is, I can only code up to 10, but they should continue to work in JRE8 as long as I don't use any of the 9+ shortcuts? – trilogy Oct 10 '18 at 13:59
  • 1
    I think there must be two applications, one for JRE 8, the other for 9+. already OpenJFX based. With programming mainly for 8, integration build for both. And at some time in the future developers will want to use 11+ notations and modules. It will be interesting to see how this is dealt by software producers / open source projects. – Joop Eggen Oct 10 '18 at 14:19