Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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

I would like to completely remove Apple's Java 6 and make Oracle's Java 7 default for every program. For example, with Eclipse I had to fiddle with eclipse.ini to specify JAVA_HOME for Java 7, and the same for TunnelBear. No luck for Aptana, though (it still wants Apple's Java) Is there a way to make Oracle's Java default in terms of PATH?

share|improve this question
1  
I think Java 7 is the default for PATH as /usr/bin/java should be Java 7 . However the issue is with .apps having something else in their .plist files – Mark Feb 6 '13 at 19:27

Download and install the latest Java Development Kit (JDK) from Oracle, which will place it in /Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk (or whatever the latest version is). Now, start Terminal.app, and enter the following commands:

  1. cd /System/Library/Java/JavaVirtualMachines (change to the proper directory)

  2. sudo mv 1.6.0.jdk backup.1.6.0.jdk (keep the old JDK around, just in case - you will need to have an administrator password to do this)

  3. sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk 1.6.0.jdk (link your new JDK installation to where applications expect the old one to be)

Keep in mind that with any further jdk updates, you'll need to update the symlink to the new directory:

sudo rm /System/Library/Java/JavaVirtualMachines/1.6.0.jdk && sudo ln -s /Library/Java/JavaVirtualMachines/new_jdk_version /System/Library/Java/JavaVirtualMachines/1.6.0.jdk
share|improve this answer
    
You shouldn't create the 1.6.x symlink, application won't be expecting the jdk to be in /System. If anything you should set JAVA_HOME in your profile. – anddam Oct 21 '14 at 6:47

These instructions worked well for me on OS X Mavericks.

  • Remove Apple's JVMs

    $ sudo rm -rf /System/Library/Java/JavaVirtualMachines/
    
  • Remove installer records

    $ sudo rm /private/var/db/receipts/com.apple.pkg.JavaForMacOSX*
    
  • Remove installer receipts (delete the <dict>...</dict> entries that reference com.apple and java)

    $ sudo emacs /Library/Receipts/InstallHistory.plist
    
  • Set the symlinks for Java 7

    $ sudo rm /usr/bin/java
    $ sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home/bin/java /usr/bin/java
    
  • Optionally symlink JAVA_HOME

    sudo rm /Library/Java/Home
    sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home /Library/Java/Home
    
share|improve this answer

Well, if you install the latest Java update from Apple, that should actually uninstall Java 6. You can go to Oracle's website directly to download Java 7. That's what I did. With only Java 7 on your system, that should make it default.

share|improve this answer
    
On Lion the Java update did not uninstall Apple's java - /usr/bin/java is now Java 7 but Java 6 is still useable as /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java – Mark Feb 6 '13 at 19:25
    
I'm using Java 7 only and getting Apple updates on Java is somewhat tedious. I want it out - anyone managed to have it that way, yet? (i.e. so much out that Apple wouldn't push Java-specific updates; I'm fine taking all through Oracle directly). – akauppi Mar 5 '13 at 11:40

I know this is an old thread, but if one has Adobe CS5 on their machine, it MUST HAVE the Apple 1.6 version of java for the suite to run. I was running Eclipse which needed 1.7 or higher. I thought it would replace the Apple version, but it didn't. The Apple version is in the System/Library folder and the Oracle version is in the Library folder.

Thought I would add a bit more info for those who may need this information.

OS X Lion

share|improve this answer
    
That info is in the other answers – Mark Mar 30 at 0:48
    
Didn't check. Sorry. – kdd Mar 31 at 17:22

Your Answer

 
discard

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.