Will compiling for Java 1.5 on Java 1.7 still work?

TheLQ picture TheLQ · Oct 22, 2011 · Viewed 10.8k times · Source

I've recently moved to Java 7 in one of my projects. I claim that it can run on Java 1.5 simply because there's nothing I depend on that is in Java 6 or 7. However when compiling today I noticed this:

bootstrap class path not set in conjunction with -source 1.5

Google has found little information on this warning. Does this mean that you can't compile to Java 1.5 from Java 1.7?

Answer

paulsm4 picture paulsm4 · Oct 22, 2011

This Oracle blog explains the warning:

http://blogs.oracle.com/darcy/entry/bootclasspath_older_source

The reason is, that if you fail to set rt.jar for the older platform, then:

If the second step is not taken, javac will dutifully use the old language rules combined with new libraries, which can result in class files that do not work on the older platform since references to non-existent methods can get included.