Use of javc --release option with JavaFX

David Holmes david.holmes at
Thu Oct 5 04:54:54 UTC 2017

Hi Matthew,

On 5/10/2017 2:17 PM, Matthew wrote:
> How exactly should the new release flag work when JavaFX is used.  Consider the following very simple (and not very useful) class (
>          import javafx.application.Application;
>          public class Testing {            public static void main(String... args) {}        }
> This compiles perfectly fine under (Oracle's release of) JDK 8 using the command
>          javac
> and compiles just fine under JDK9 using the same command.  However when trying to target java 8 with JDK9 using
>          javac --release 8
> it results in an error
> package javafx.application does not exist
> I have tried using the --add-modules option to include the JavaFX modules, but this flag does not work with release 8 targeted.  It does work if the jfxrt.jar file from the JDK8 directory is explicitly added to the classpath.  However, this requires us to have that file around, and thus have a second version of the JDK installed.
> Is this the desired behavior?  I know that the release flag should release us from needing to set the bootclasspath to the desired rt.jar file, but should something that compiles fine under JDK8 and JDK9 with no extra jars (or even command line flags) needed require an extra jar when targeting java 8?

JavaFX is an extension provided as part of the JRE. The docs for 
--release say:

--release release
     Compiles against the public, supported and documented API for a 
specific VM version.

I'd say that an extension does not fit that description (though I 
dislike the description as it refers to the VM).

So yes you will need the fx jar file available.


More information about the jdk9-dev mailing list