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

Solution 1:

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!

Solution 2:

when I do a java -version it still says Java 7.

Related, with an explanation: Why does the version of Java verified by Oracle differ from the version shown at the command line?

I tried downloading this Java for OS X update … when I try to install it I just get this message:

A newer version of this package is already installed.

For the outdated installer (2011-11-08), that's the proper response.

Current: Java for OS X 2012-006, which normally uninstalls the Apple-provided Java applet plug-in from all web browsers.

If you then allow or force installation of an outdated plug-in, please take care with all applications that will use the plug-in. (Consider vulnerabilities and so on.)