NOTE: This appears to be a limit in the \"javac\" program.
I have Java 6 code that needs to be built for a Java 5 JVM. My previous work with the javac ant target (
I believe you need to set -bootclasspath as well so that javac compiles against JDK 1.5 bootstrap classes.
Try:
javac -source 1.6 -target 1.5 -bootclasspath /path/to/jdk1.5/lib/rt.jar -extdirs "" Foo.java
UPDATE:
Try removing the -source option, but keep the -target option.
I just tested it out:
# no source, only target => COMPILES to 1.5
$ javac -target 1.5 Foo.java
$ javap -v Foo | grep version
minor version: 0
major version: 49
# no source, no target => COMPILES to 1.6
$ javac Foo.java
$ javap -v Foo | grep version
minor version: 0
major version: 50
# both source and target => ERROR
$ javac -source 1.6 -target 1.5 Foo.java
javac: source release 1.6 requires target release 1.6
$ javac -version
javac 1.6.0_21