This behaviour appeared strange me. The following is what happened:
- We have a build.xml file for Ant, which says
<javac source="1.5" target="1.5"></javac>
. - We have updated Java on our system (Linux) to 1.6, but we forgot to update the Ant build.xml file.
- Ant building is happening successfully, How is it happening? Is it like the higher version of Java can downgrade to lower versions? Or if Ant cannot find the version of Java specified it uses the default version?
These options are passed on to the Java compiler. It can generate byte code for older JVMs (target) and it can also accept source written for older Java versions (source). This makes for example sense, when a new Java version introduces new keywords but you use that word as identifier in your source.
It will generate the byte code of JDK 1.5 instead of JDK 1.6, because Java supports backward compatibility so byte code of JDK 1.5 could easily run on JDK 1.6 JRE.
There will not be any problem in upgrading JDK in this scenario
Means that it tells Java compiler that source is written using Java 1.5 and it should create the target build suitable for Java SE 1.5 environment.This is really possible with newer JDK.This is exactly the same as
Please refer the documentation of the javac tool
Hope this helps