Quote from this post:
Java 5.0 and 6 used to have poor support for compiling classes to
target older versions of Java. It always supported the previous
version, but often no more. Even if you could compile for previous
version, you had to be careful not to use functionality which did
exist in the previous versions.
You should either include -Xbootclasspath
when using javac:
javac -Xbootclasspath:/path/to/jdk6/rt.jar -target 1.6 -source 1.6 Main.java
or compile using -target 1.7
(or higher of course):
javac -target 1.7 -source 1.7 Main.java
or use javac
of jdk 6:
/path/to/jdk6/bin/javac Main.java