New feature in JDK 9 builds: javac -release $VERSION
joe.darcy at oracle.com
Mon Jul 13 03:50:54 UTC 2015
As of JDK 9 b72 , 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 . 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.  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.  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 openjdk.java.net.
 "How to cross-compile for older platform versions,"
 JEP 182: Policy for Retiring javac -source and -target Options
More information about the jdk9-dev