Pre-Java 9 -source and -target options

The -source option specifies the Java SE version and has the following acceptable values:

Value Description
1.3 javac does not support features introduced after Java SE 1.3.
1.4 javac accepts code with language features introduced in Java SE 1.4.
1.5 or 5 javac accepts code with language features introduced in Java SE 1.5.
1.6 or 6 javac reports encoding errors as errors instead of warnings. Of note, no new language features were introduced with Java SE 1.6.
1.7 or 7 javac accepts code with language features introduced in Java SE 1.7. This is the default value if the -source option is not used.

The -target option tells javac what version of the JVM to target. The acceptable values for the -target option are: 1.1, 1.2, 1.3, 1.4, 1.5 or 5, 1.6 or 6 and 1.7 or 7. If the -target option is not used, the default JVM target is dependent on the value used with the -source option. Here is a table of -source values with their associated -target:

-source value default -target
unspecified 1.7
1.2 1.4
1.3 1.4
1.4 1.4
1.5 or 5 1.7
1.6 or 6 1.7
1.7 1.7
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset