Reputation: 13729
Does Hello World!
program compiled by JDK 7u3 runs with an older JREs (eg. JRE 6)?
If the answer is YES
, When a java program doesn't run with an older JRE?
Upvotes: 1
Views: 259
Reputation: 147164
By default the class files produced by javac will have a version number appropriate for the JDK they were produced on. To produce class files for earlier versions you will need to specify -target
and to do that you will also need -source
. -source 1.6 -target 1.6
say.
However, you will still be picking up the current Java library, which contain classes, methods (possibly overloads), etc., that were not in the previous version. To sort that out, use -bootclasspath
to point to the rt.jar
of the target JRE.
Upvotes: 7
Reputation: 3685
Nope. You will get classloader exception complaining about non supported class version. Unless of course you specifically target lower version when compiling
Upvotes: 3