New feature in JDK 9 builds: javac -release $VERSION

joe darcy joe.darcy at
Mon Jul 13 03:50:54 UTC 2015


As of JDK 9 b72 [1], a feature recently pushed by Jan Lahoda is now 
available: the javac -release command line option.

This feature was developed under JEP 247: Compile for Older Platform 
Versions [2]. In brief, to use javac to cross-compile to an older 
release of the platform it is not sufficient to just set the -source and 
-target options to the older value; the bootclasspath must also be set 
to correspond to the older release too. [3] Setting the bootclass was 
often forgotten and acquiring the needed information could be inconvenient.

The -release flag in javac addresses both of these shortcomings. Now 
only a single flag (-release) needs to be set to cross compile compared 
to three flags (-source, -target, -bootclasspath) and the needed 
information is included in the JDK. The set of release values follows 
the same "one plus three back" policy now used for the -source and 
-target options. [4] Therefore, in JDK 9, the accepted argument values 
for -release are 6, 7, 8, and 9.

Feedback on the this feature can be sent to compiler-dev at





[3] "How to cross-compile for older platform versions,"

[4] JEP 182: Policy for Retiring javac -source and -target Options

More information about the jdk9-dev mailing list