5

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.

Graham Perrin
  • 7,739
  • 14
  • 81
  • 245
Steph
  • 153
  • Yep, see my answer here – Ethan Lee Nov 23 '12 at 02:15
  • Hmmm, that didn't seem to work for me. I tried it but when I do a java -version it still says Java 7. – Steph Nov 23 '12 at 03:14
  • 2
    It's weird, that one actually installs, which is awesome, but then when I do java -version it still says Java 7. I can't seem to find anywhere where it installs Java 6 either. I was looking in /Library/Java/JavaVirtualMachines but I only find jdk1.7.0_09.jdk in there. – Steph Nov 23 '12 at 19:11
  • I'm not familiar with system requirements for development for Android. I assume that you may concurrently run (a) at the command line, a version of the JRE that's suitable for Android development; and (b) plugged in to the web browser, a possibly different version of the JRE (whichever is preferable for apps that use the Internet plug-in). – Graham Perrin Nov 26 '12 at 08:38
  • Re http://apple.stackexchange.com/questions/72382/how-to-reinstall-java-6-for-development-for-android-on-mountain-lion/72674#comment84451_72674 I don't treat this question as a duplicate, it's specific to development for Android. Does any aspect of that development require the Internet plug-in? – Graham Perrin Nov 26 '12 at 10:08

2 Answers2

2

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!

Yes Barry
  • 668
  • This worked! After I ran both of those delete commands, I tried a java -version and it said No Java runtime present, requesting install. and it opened a window that allowed me to automatically download Java 6 and install it again. Thank you so much for the help! – Steph Nov 24 '12 at 06:16
  • After following the steps in this answer, please: which version is shown by Oracle's verification routine? – Graham Perrin Nov 25 '12 at 18:25
  • @GrahamPerrin It just keeps spinning and never says anything. – Steph Nov 26 '12 at 03:40
  • Not explicit in this answer: if you have not already done so, quit the browser and all other apps that use the plug-in. In addition to Oracle's routine you may use http://javatester.org/version.html to discover the version of the JRE that is plugged in (without attention to the version that is not plugged in). – Graham Perrin Nov 26 '12 at 06:29
  • 1
    +1 complementary because for as long as Oracle's misleading terminology is lodged in people's memories, answers may be difficult to express. During this period of transition (Apple-to-Oracle) I habitually read between the lines of questions, and sometimes answers, relating to Java ;-) – I encourage you to edit your own answer based on what you find. – Graham Perrin Nov 26 '12 at 07:38
  • For Mavericks, you also need to remove /System/Library/Frameworks/JavaVM.framework – Anjan Biswas Mar 21 '14 at 08:35
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.)

Graham Perrin
  • 7,739
  • 14
  • 81
  • 245