MacOS – How to reinstall Java 6, for development for Android, on Mountain Lion

androidjavamacos

Requirement

Java 6 for Android development on Mountain Lion.

Question

Is it possible? What can I do?

I've looked everywhere for a way to do this and am unable to find any solution.

Background

I recently installed Oracle's Java 7 for OS X on my Mac running Mountain Lion (10.8.2). I was happy with this until I started doing Android development, which throws errors relating to Java 7.

I downloaded Apple's Java for OS X Lion Update 1, but when I try to install it I get only this message before Installer closes:

A newer version of this package is already installed.

I followed Oracle's instructions (Mac FAQ), but they seem to not work for me. Afterwards if I do java -version it still says Java 7.

I even tried restarting my computer, to no avail.


Before I tried to reinstall Java 6, Apple's Java Preferences utility (described by Oracle) was present, but after trying all these things I am also without Java Preferences.

Best Answer

From my understanding the actual components that need to be removed first are in /System/Library/Java/JavaVirtualMachines/*.jdk

So if you get rid of those:

$ sudo rm -rf /System/Library/Java/JavaVirtualMachines/*

Also, as you mentioned, you're supposed to remove this:

$ sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin

At this point it should simply be a matter of downloading 1.6 and installing it. If you do $ whereis java you will see that the java binaries are stored in /usr/bin/{java,javac,etc}. But $ java -version apparently gets its information from the first folder I mentioned you should delete.

After you remove those, try running $ java -version again. You should be prompted to install it.

Hope this helps!