Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The first time I tried to use Java on Mountain Lion, it installed automatically. Unfortunately, it installed Java 6, so I installed Java 7. If I navigate to Java in System Preferences, only Java 7 is listed. How do I switch to Java 7, or remove Java 6?

share|improve this question
up vote 6 down vote accepted

Apple's tools don't see Java 7, Oracle's tools don't see Java 6; it's all a bit ugly. Luckily there's an ugly fix to go with it!

Normal Mac Java 6 running on 10.8:

java -version
java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode)

Install the Java 7 JDK (not just the JRE) from Oracle.

Move the system java out of the way (so you can get it back if you want):

sudo mv /System/Library/Java/JavaVirtualMachines/1.6.0.jdk /System/Library/Java/JavaVirtualMachines/1.6.0.jdkx

Then symlink 7 in place of 6:

sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_06.jdk /System/Library/Java/JavaVirtualMachines/1.6.0.jdk

and voila:

java -version
java version "1.7.0_06"
Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
Java HotSpot(TM) 64-Bit Server VM (build 23.2-b09, mixed mode)

I've not had trouble with any java apps so far (apart from java preferences which checks which java it's running under).

There's probably a better way of doing this, but it works for me.

share|improve this answer
I found that I had to open Java Preferences after doing this and drag java7 to the top of the the preferred order dialog which was presented, otherwise java6 was still used – ianbarker Sep 6 '12 at 8:24

To switch to Java 7 for when Java is run from the terminal, I added the following line to ~/.profile:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_06.jdk/Contents/Home
share|improve this answer

$ cp -r /Library/Java/JavaVirtualMachines/jdk1.7.0_12.jdk /System/Library/Java/JavaVirtualMachines/

$ sudo ln -sF /System/Library/Java/JavaVirtualMachines/jdk1.7.0_12.jdk CurrentJDK

$ java -version java version "1.7.0_12-ea" Java(TM) SE Runtime Environment (build 1.7.0_12-ea-b05) Java HotSpot(TM) 64-Bit Server VM (build 24.0-b26, mixed mode)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.