Does anyone know the difference between using --release and the older -source and -target command line parameters?
In the javac man page: -source Provide source compatibility with specified release -target Generate class files for specific VM version
--release Compile for a specific VM version. Supported targets: 6, 7, 8, 9, 10, 11
Could --release bind both -source and -target to the same version?
The --release
flag not only sets source and target versions, but it also causes the compiler to use the symbol table for the JDK libraries corresponding to the specified release, preventing you from accidentally using APIs that are present in the compilation JDK but not present in the specified version. The --release
flag was added later, and in most cases, should replace uses of --source
and --target
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With