I needed to have Java 1.6 run on OS X 1.9, Mavericks. I had written about this before in Installing Java 6 on OS X Mavericks, but I was not confident with the solution. Today I decided to install Apple's Java 1.6 and see what happened. Would I have have to rebuild my whole machine? No. Nothing bad happened and so far so good. So, to install Java 1.6 do the following:
Download and install Java 1.6 from http://support.apple.com/kb/dl1572 and install.
Set Java 1.6 as your default using
/usr/libexec/java_home -v 1.6For more information on java_home see superuser.com.
I need to use NetBeans 7.3.1 (newer versions require Java 1.7) which is downloaded from https://netbeans.org/downloads/7.3.1.
To ensure that NetBeans runs using Java 1.6 edit the configuration file /Applications/NetBeans/NetBeans 7.3.1.app/Contents/Resources/NetBeans/etc/netbeans.conf -- which is actually a bash script! -- and define the netbeans_jdkhome environment variable
netbeans_jdkhome=$(/usr/libexec/java_home -v 1.6)
And that is it. You now have Java 6 and Java 7 on your Mac. If you want Java 1.6 to be the default for you always then add the following to your rc script
export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)