Alex Rivera | Logout

Is it possible to compile class files with the Java 7 SDK which can run on Java 6 JVMs?

Asked 2012-04-11T14:20:22.523
23

Since the public Java 6 SE JRE is getting closer to it's EOL (Nov '12), I'm considering porting my projects from Java 6 to Java 7. This would'nt be a big deal, if Apple would provide a Java 7 JRE for Mac OS X. But since Apple isn't willing to do so, I still have to support users which only have a Java 6 JRE.

Is there a way to compile Java 6 compatible binaries (class files) with the Java 7 javac? Certainly I'm aware that I can't use the new Java 7 features when doing so.

Thanks in anticiption!

Edit
Report

1 Answer

5

i have jdk6 installed. if you check the man page of javac:

Cross-Compilation Options
          By default, classes are compiled against the bootstrap and extension classes of the platform that javac shipped with. But javac also supports cross-compil‐
          ing, where classes are compiled against a bootstrap and extension classes of a different Java platform implementation. It is important to use -bootclasspath
          and -extdirs when cross-compiling; see Cross-Compilation Example below.

         -target version
            Generate class files that target a specified version of the VM. Class files will run on the specified target and on later versions, but not on earlier
            versions of the VM. Valid targets are 1.1 1.2 1.3 1.4 1.5 (also 5) and 1.6 (also 6).
answered 2012-04-11T14:24:18.833

Your Answer