Reputation: 674
This behaviour appeared strange me. The following is what happened:
<javac source="1.5" target="1.5"></javac>
.Upvotes: 1
Views: 1138
Reputation: 1445
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.
Upvotes: 0
Reputation: 12880
There will not be any problem in upgrading JDK in this scenario
<javac source="1.5" target="1.5"></javac>
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
javac -source 1.5 -target 1.5
Please refer the documentation of the javac tool
Hope this helps
Upvotes: 1
Reputation: 43728
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.
Upvotes: 1