Tag Archive for JDK

Mountain Lion Java 1.6 with 1.7 Already Installed

Reading online about how to install Java 1.6 on fresh install of Mac OS X Mountain Lion (10.8) all of the instructions say to run “java -version” from Terminal.app and this will prompt you to run the Java 1.6 installer. This is the last version created by Apple for Java 1.7 later you have to get the installer from Oracle.

When I was setting up my new computer, I did just that unfortunately the Java 1.6 install wouldn’t start as the App Store app was currently running and installing Xcode. In the meantime I went to Oracle’s site and grabbed the latest version of Java 1.7 JDK. (Java SE 7u21) I ran the installer, everything went well. I opened a new Terminal typed in “java -version” and got back java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b12)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
and all was right.

Later after XCode was installed I figured it was time to install Java 1.6, except that the common solution of typing “java -version” would no longer work as there was currently a version of Java installed and the installer dialog was no longer triggered. Fret not though child for if you search the Apple Developer Site you can find Java 1.6 installer

Once you’ve installed it you can use can use the commands I mention in this post to easily switch between the two.

Building my own fusion drive.

Building my own fusion drive.

Share

Using both Java 1.7 and 1.6 on Mountain Lion

Here’s the situation you need to use both JDK 1.7 and JDK 1.6 for different projects you are working on with Mac OS X. You already have Java 1.6 installed and ran the installer for Java 1.7 from Oracle but no matter what you do java -version will only show 1.6.

Here’s what you do to use 1.7 run the following:
sudo rm /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/ /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK

To use 1.6 run the following:
sudo rm /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
sudo ln -s /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK

Note you may have to adjust for the exact version for example if you installed jdk1.7.0_12.jdk.

Here’s an example:
thor:~ dan$ sudo rm /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
thor:~ dan$ sudo ln -s /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
thor:~ dan$ java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06-451-11M4406)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01-451, mixed mode)
thor:~ dan$ sudo rm /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
thor:~ dan$ sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/ /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
thor:~ dan$ java -version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b12)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

Share