1

I need to target Java 7 and would like to use JavaFX and FXML on that project. We have some working code for Java 8 and it would save an immense amount of time if we can retro-fit those modules to Java 7.

I'm posting because I'm getting compile errors on the first attempt. In the first instance, I can't find the @FXML annotation, package:

  • import javafx.fxml.FXML

In Java 8 JDK. However that just a for instance example.

I was hoping to find Java 7 JDK JavaFX documentation. The searches and tutorials seem to be either aimed at Java 8 and/or not about things that work differently between the two

The solution is some documentation describing what's different in Java 8 JDK JavaFX to Java 7's JavaFS JDK? Google isn't giving me much satisfaction and most of the Stackoverflow questions are going the other way. I suppose it is rare for someone to ask how to go back a version. Any one seen, know of or some release notes on code differences (or a migration guide??). Many thanks in advance.

will
  • 4,799
  • 8
  • 54
  • 90

1 Answers1

1

JavaFX 2 is the version of JavaFX included in Java 7. All of the Oracle JavaFX 2 documentation is currently available online (it may be removed at some time in the future in the same way JavaFX 1 documentation was removed). FXML is supported in Java 7, there were no significant changes to FXML for Java 8, so any FXML specific information you read for Java 8 will also be relevant for Java 7.

You don't really need a backward migration guide I think (not that any such guide would exist anywhere anyway). You can just compile your program against the most recent version of Java 7 and fix any compile errors that occur by removing any lambda references and coding against the older API. Unless you are using JavaFX 3D or printing or some such feature which was completely new in Java 8, I can't really see backward conversion being much of a problem or an extremely large task (90%+ of the public API will be unchanged).

One reason you are getting compile errors such as class not found is because you need to explicitly add the JavaFX 2 runtime to the compile and runtime classpath (for Oracle Java 8, this requirement was removed). See the answer to Compile code using JavaFX 2.0 (using command line) for more details.

I'd recommend against backporting code anyway as there were so many improvements in JavaFX 8. Also Java 7 has a limited support life. If you bundle your app as a self-contained application, then you have control of the Java runtime that the app runs on, so Java 8 would be an obvious choice for such a scenario. But I guess you may have some constraint which forces you to code to Java 7 (which you don't need to outline here).

Community
  • 1
  • 1
jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • Some customers insist on NOT migrating to a new Java version; it is out of our hands in those situations. Will see if we can convince them. – will Dec 12 '14 at 01:41