Use of javc --release option with JavaFX

David Holmes david.holmes at oracle.com
Thu Oct 5 06:10:11 UTC 2017


On 5/10/2017 3:27 PM, Matthew wrote:
> I had expected as much, but wanted to be absolutely sure.  Is JavaFX still considered an extension moving forward?  For example, when Java 10 releases at some future point, if I use
>      javac --release 9 Testing.java
> will it work correctly with the JavaFX classes, or will I need to find a jfx jar?

The status of JavaFX is unchanged as far as I know. But there is no 
jfxrt.jar in 9. Not sure how Java 10 will handle --release 9.

Might be worth asking on the javac mailing list: 
compiler-dev at openjdk.java.net

David

>      On Wednesday, October 4, 2017, 11:55:01 PM CDT, David Holmes <david.holmes at oracle.com> wrote:
>   
>   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 (Testing.java)
>>            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 Testing.java
>> and compiles just fine under JDK9 using the same command.  However when trying to target java 8 with JDK9 using
>>            javac --release 8 Testing.java
>> it results in an error
>>            Testing.java:1: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.
> 
> David
>    
> 


More information about the jdk9-dev mailing list