I am trying to create a GUI application created using JavaFX and targeting java 8 with the flag of the new version of java 9.
compilation
import javafx.application.Application; public class Testing { public static void main(String... args) { } }
when setting up java 9 with
javac Testing.java
works fine (also when using --release 9 ), but when I add the release flag
javac --release 8 Testing.java
cannot compile, no errors exist
Testing.java:1:error: package javafx.application does not exist
No problem compiling in javk javac. I tried using the --add-modules flag to add jfx modules, but this flag is not allowed when setting release to 8.
Is there any way to make this work under java 9? It doesn't seem like he thinks jfx packages are included in java 8, but they are (at least in oracle release).
I am using version java 9 for release on Windows and building the same application without problems in the latest version of java 8.
I tried adding jfxrt.jar from my java 8 installation (not rt.jar ) to the class path when compiling with the --release 8 flag and it works.
I understand that one of the goals of the release flag was to remove the need to have several versions of the JDK installed (or at least their rt.jar files). I'm not sure if the intention was only to remove the compilation need for this single file, or if the goal was to remove the compilation need for any packed JDK files (and jfxrt.jar included in JDK8 [at least in the Oracle version], which does not require any either special flags or modifications to the path to it).
Not sure of the intention, it somehow seems wrong that something will compile fine under java 8, but to compile (and only compilation is not required) compilation (and only compilation fails) under java 9 targeting to java 8 (but not when targeting java 9), and therefore several JDKs are required. For those who are more familiar with the intended implementation of the release flag, should this work this way?