O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Compiling for older platform versions

We have at some point used options -source and -target to create a java build. The -source option is used to indicate the version of java language accepted by the compiler and the -target option is used to indicate the version supported by the class files. Often we forget to use -source option and by default, javac compiles against the latest available Java version and due to this there are chances of newer APIs being used and as a result, the resultant build doesn't run as expected on the target version. 

So as to overcome the confusion of providing two different command line options, a new command line option --release is introduced in Java 9. This acts as a substitute to -source, -target and -bootclasspath ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required