I need to be able to build and run Java tools under Java 6. When I got my new MacBook Pro I also got an unexpected problem and that is that there is no Java 6 for OS X 10.9. Or perhaps I should say that I did not know enough to know if I could get Java 6 for OS X 10.9. And so the machine become used as a very fast web browser.
Today I decided to make some effort to get Java 6 running. If this machine were Linux or Windows I would not have this issue. The Java packages for these operating systems use the standard Java distribution and configuration. Not so with Apple's Java. It seems like a mess to me when I compare both the standard distribution's file and directory names to Apple's and even between Apple's OS X Java 6 and Oracle's OS X Java 7. Clearly, I am not an Apple developer.
Apple's Java 6 package can be downloaded from
http://support.apple.com/kb/DL1572.
I don't really need Java 6 to run, I only need Java 7 to compile and run like Java 6. And for this I only need to configure the existing Java 7
javac and
java commands correctly. I am glad of this as I have no confidence that Apple's Java 6 installer will leave my existing Java 7 installation working. I will need to cheery pick what I want from Apple's Java 6 installation package ... and hope for the best. And hoping for the best is acceptable as, after all, this MacBook Pro is a development machine and so it can be a little rough and idiosyncratic.
I used the shareware tool
Pacifist to extract the JavaForOSX.pkg sub-package to my ~/lib/ directory. (Pacifist is very easy to use and so I could skip understanding
pkgutil.) I renamed the installed root directory from "JavaForOSX Folder" to ~/lib/jdk1.6.0 and fixed the permissions.
My builds are handled by Ant and so I need to tell the
javac task to use Java 6 for source and target, and to point the bootclass to the Java 6 jars.
<path id="java6.bootclasspath">
<fileset dir="${env.HOME}/lib/jdk1.6.0/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes">
<include name="**/*.jar"/>
</fileset>
</path>
<javac
source="1.6"
target="1.6"
bootclasspathref="java6.bootclasspath"
... >
...
</javac>
The compile now works. Have not yet tried to run, however. Running is for another day.