Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have two versions of Java installed with Mountain Lion:

The update from Apple removes Java Preferences. In another question someone wonders about the removal of that utility.

My question is different:

  • how can I switch between the two versions now that Java Preferences is gone?

I previously used Apple's utility to set Java preferences with ease. Without that utility, is there an easy and fast way?

share|improve this question
Is there some reason you can't reinstall Java Preferences? –  chharvey Oct 27 '12 at 19:11
@TestSubject528491 How can I do that? –  Maverik Oct 27 '12 at 19:22
I think this will help you, I have not tried it in my machine yet. See step 12 and 13 from the following link wikihow.com/Install-Oracle-Java-on-Ubuntu-Linux. You can repeat the steps to shift between java.. hope this helps you.. –  Dilip Rajkumar Oct 31 '12 at 8:06
@DilipRajkumar It is for linux.... –  Maverik Oct 31 '12 at 8:14
Sorry I wrongly assumed that the linux command will work on Mac.. If I get lucky with another solution i ill suggest.. –  Dilip Rajkumar Oct 31 '12 at 8:58

5 Answers 5

up vote 11 down vote accepted

You may need two approaches:

  • one to switch the version for the applet plug-in alone
  • another approach to switch the version for other parts of the JRE without switching the version for the applet plug-in.

My recent use case:

  • Java 8 for apps that do not use the plug-in
  • Java 7 Update 9 for the applet plug-in.

To switch the applet plug-in but not other parts of the JRE/JDK from Java 8 to Java 7 Update 9

  1. quit web browsers and any other apps that use Java or the Java applet plug-in
  2. install JDK 8
  3. set aside the plug-in
  4. install JRE 7 Update 9 or JDK 7 Update 09.

Setting aside: suggested move

sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin /private/var/tmp

If you plan to switch frequently, you may prefer a different temporary location.


sh-3.2$ java -version
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b58)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b02, mixed mode)
sh-3.2$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.8.2
BuildVersion:   12C60

At the same time:

Screenshot of Oracle's verification of Java version in Safari

To switch the applet plug-in but not other parts of the JRE/JDK from Java 7 Update 9 to Java 6 Update 37

Answers under:

To switch the JRE but not the applet plug-in from Java 8 to Java 7 Update 9

Install JDK 7 Update 09 then JDK 8

  • the OS and apps will default to use the greatest version.

Quit any apps that use Java. No need to quit the browser.

Set aside the jdk1.8… directory from


  • the OS and apps will use Java 7 Update 9.

To switch the JRE but not the applet plug-in from Java 7 Update 9 to Java 6 Update 37

Quit any apps that use Java. No need to quit the browser.

Set aside the jdk1.7… directory from


  • the OS and apps will use Java 6 Update 37.


macbookpro08-centrim:~ gjp22$ java -version
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)
macbookpro08-centrim:~ gjp22$ sudo mv /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk /private/var/tmp
macbookpro08-centrim:~ gjp22$ java -version
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)


For users of OS X, some of what's provided by Oracle is initially misleading:

… and so on.


Whilst none of the above is as simple as switching with the Java Preferences app previously installed by Apple, the relatively simple approach of setting aside (no need for special uninstallation) is reminiscent of the wish for drag-and-drop installation … previously expressed in the openjdk-osx-build area.

Someone might like to build an app, but I should not recommend using symlinks – it would work, but could be inconsistent with future drag-and-drop approaches to installation.

Side notes

At the time of writing, the most recent supported releases for which Oracle makes updates publicly available are (for platforms other than OS X) Java 6 Update 37 and (for platforms including OS X) Java 7 Update 9.

As greater releases will be made available, please reinterpret this answer accordingly.

Java version terminology in this answer is in line with Java Help Center terminology.

share|improve this answer
Are you really referring to Java 8 or is it an error ? :-) –  Maverik Nov 6 '12 at 0:48
Really ;-) … please see the linked questions, right hand column. –  Graham Perrin Nov 6 '12 at 3:07
Here's a tip if you're using JDK8 and want to switch frequently. Simply chmod 0000 the JDK8 directory to turn it off sudo chmod 0000 /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/ and to turn it back on sudo chmod 0755 /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/. –  Brett Ryan Feb 17 '13 at 23:43
Last suggestion by @BrettRyan worked perfectly for me. I think it is the easiest way to go. –  Artem Apr 12 '14 at 1:32
Thank you very much @BrettRyan that was the simplest one!!! I suggest the author of the answer to add it an alternative. I have created a .sh in my home folder with the commands, and created an Automator binded to a key that switches from one to another. Amazing! –  Panthro May 19 at 12:23

Open up a terminal use this command:

/usr/libexec/java_home -v 1.6 

You can change the 1.6 to any version of java you want to use and the command will output the location of where that version of java resides. (i.e: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home)

then you can set the JAVA_HOME like you normally would with the output of the previous command. i.e.:

export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

So to simplify; something like this should work:

export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)

remember to check the version with:

java -version

Hope it helps.

share|improve this answer
This is the single most useful answer to this problem that I could find anywhere online. THANK YOU! –  SearchTools-Avi Jul 17 '13 at 19:01
Ok, THIS should be the accepted answer. I have a mandatory update JAR for an application server I have installed and it will ONLY run on Java 6. Using this, I was able to switch to Java 6, run the updater, then switch back. Now I can update the application server to run on Java 7. –  Adrian J. Moreno Apr 16 '14 at 5:33

It looks like you'll have to do it manually. Oracle's documentation states that only one JRE can be installed at a time.

This Apple support page describes how to switch between the Apple SE 6 JRE and the Oracle SE 7 JRE. Briefly, to switch from Oracle's JRE back to Apple's, start the Terminal app and type the following:

sudo mkdir -p /Library/Internet\ Plug-Ins/disabled

sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/disabled

sudo ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI.plugin /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin

There are more (and better) instructions on the support page on how to switch Web Start back to JRE 6, and how to switch everything back to Oracle JRE 7 (reinstall the JRE).

Not as simple as using the Java Preferences utility, but better than nothing.

share|improve this answer
Oracle's recent use of the term JRE is misleading to users of OS X. The JRE is much more than the plug-in. –  Graham Perrin Nov 3 '12 at 18:39

based on user2343996's answer

alias java8="export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) && java -version"
alias java6="export JAVA_HOME=$(/usr/libexec/java_home -v 1.6) && java -version"
share|improve this answer

Why do you need to have 2 versions of Java installed?

Apple doesnt have Java installed as a default update (from Lion onwards I believe). The best way to check for/install Java on a Mac is as follows :

  1. Open Terminal. Type "java" (without the quotes of course)
  2. If java isn't present you get the following : "No Java Runtime present, requesting install…"
  3. Java starts installing normally (this is the false executable starting the install)
  4. If you have java to check the version, in terminal type "java-version"

If you want to install a different version of java : Just goto the oracle site and download the newest/older jdk.

share|improve this answer
I already have two versions of Java as I wrote in the question. I'm asking how to change the default one. –  Maverik Oct 29 '12 at 10:06
I think it automatically switches to the newest version/latest version installed. In my case I installed jdk 7 last. So that's the one that works by default. –  SashaZd Oct 29 '12 at 14:21
I want to be able to switch between versions. –  Maverik Oct 29 '12 at 14:58
There are differences between the Apple JDK 6 and the Oracle JDK 7 that can cause incompatibilities, both at compile time and at run time. –  JohnnyO Nov 1 '12 at 17:41
In general, we don't try to change someone's premise unless we can offer a competing or compelling alternative when the answer is simply no. We also discourage asking for votes so I've edited that out of your answer. –  bmike Nov 5 '12 at 21:12

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.