Create a gist now

Instantly share code, notes, and snippets.

@johan /
Last active Oct 2, 2017

What would you like to do?
osx + java 7 = painfully easy

Step 1

Does your osx terminal speak java 7? Start and try: java -version:

> java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

[angel choir bliss] It does! Proceed to step 8.

> java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

[jeopardy Wrong Answer™ beep] Ouch! You need some help. [angry klaxon sounds] Ready an aspirin; this may get painful.

Step 2

Does your system have a not-linked-for-shell use java 7 already? Try this (yes, the apostrophes are important):

> '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java' -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

If you got something like that, Othar the otter smiles upon you – proceed to step 7. If it didn't find a command like that, you need to download and install it from Oracle first.

Step 3

Head to and find the line that reads something like "Download the jre-7u6-macosx-x64.dmg file." – THIS IS A MAGIC TOKEN. You feed it to google with a supporting incantation, and it produces a web page where you can download it. If you got the above token, ask google for jre-7u6-macosx-x64.dmg and click the first result, a page probably entitled "Java Archive Downloads - Java SE 7 - Oracle". If you are in Europe, congrats! Click away the cookie banner telling you that we can make stupid laws here too. Then search for your magic token again in this page. In the section above the link, click the radio button saying "Accept License Agreement", find your token link again and click it.

Step 4

If you are now getting the file downloaded, you have already jumped the oracle hoop of patience, and been awarded the Oracle Cookie of Infinite Patience. You rock, dude! Pat yourself on the back and skip to step 6.

Step 5

Before you has just appeared another minion mini-boss looking something like this:


He demands your email address. Click the Sign Up link and share your heart at the form (he feels no pain, and deserved whatever you wrote), ending with Create. If you feel generous and feed it your proper proper address, check your mail, if you hate this kind of thing, I'd suggest feeding it whatever you like and then head over to and type in the same name in their search box to see the mail the Oracle grue sent you. Click the Account Verification Link in it, feed the grue your email address and new password if you have to. If told Your email address has been verified., press Continue. If your file finally is downloading: awesome! Proceed to step 6. Otherwise, proceed to step 3.

Step 6

Wait for jre file to download. Then double click it in your Downloads folder to mount the dmg, and go through the whole installer. You're on your own for a little bit now, trooper, but follow its instructions and you'll be rewarded with a local good-enough java install.

Step 7

...too bad this java won't run in your terminal, though. To fix that, run sudo mv /usr/bin/java /usr/bin/java-1.6 and then sudo ln -s '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java' /usr/bin/java and proceed to step 1. If it seems you are looping through this TODO and never terminating, there probably is something that needs fixing somewhere. Cry a little, then fix it, and submit a pull request.

Step 8

You made it! Reward yourself bountifully, take the rest of the day off, or whatever floats your boat.

jakegub commented Apr 30, 2014

Wow... This actually worked great. Well done sir.

jbyler commented May 27, 2014

I prefer not to replace /usr/bin/java, since that probably messes up whatever system Java Preferences uses to allow you to select which JVM is used for applets, etc.), and might get overwritten by an OS update, etc. Instead, I set JAVA_HOME to whichever JVM I want to use (e.g. /Library/Java/JavaVirtualMachines/1.7/Contents/Home) and then prepend ${JAVA_HOME}/bin to my PATH. Also, you may want to use /usr/libexec/java_home -V to find out which versions of java are installed.

Worked as advertised on OS X 10.9.4. Thanks!

Thanks for this, it works with Java 1.8 on OS X 10.10 Public Beta.

muzll0dr commented Aug 8, 2014

Brilliant, thank you.

Thank you, it worked perfectly!

Stupendously easy to follow and works flawlessly!
[angel choir bliss]

mobime commented Nov 12, 2014

You Sir, are an officer and a gentleman.

This worked for me as well! Thanks very much!

This totally does not work. The terminal just says -bash: -version: command not found when I say > java -version

Thanks a lot for the easy to follow instructions. Worked nicely.

fantastic -- this worked for me.

I feel like I just did some black magic. I downloaded jdk-8u60-macosx-x64.dmg and ran it. Then I did the sudo rm /usr/bin/java and THEN I ran sudo ln -s '/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java' /usr/bin/java. I think it wouldn't work with the quotes or the full path. Anyway, that got me the latest version and Eclipse is happily installing now.

After a few tries, this seemed to work for me. My computer is already running Java 8u65, and will not let me downgrade to 7u6. Hopefully it all works the same.

Needed a JDK, but this was still incredibly helpful. I was able to follow exactly step by step to get what I needed.

amactus commented May 18, 2016

This worked for me a few months ago on another computer. But on this one it keeps giving me and "operation not permitted" when I do step 7, what do I do?

josephspurrier commented May 23, 2016

@amactus If you get "operation not permitted", you need to disable System Integration Protection (SIP/rootless) first before it will let you make any changes to files in /usr/bin:

  • Reboot and hold down: command + r
  • Utilities -> Terminal
  • Type in then press enter: csrutil disable;reboot

ios122 commented Oct 27, 2016

Directly install the corresponding version of the JDK, rather than the installation of JRE, is the most simple way to solve this problem.

Umm, i did it at i went through and endless loop. first it said:
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468-11M4833)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)
mikes-iMac:~ admin$

so i went to step 2 and it gave me:
/Home/bin/java' -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
mikes-iMac:~ admin$

which is not what it said it was suppost to be. so i went to step 7 and so it told me to go to step 1.

I just kept repeating the steps!!!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment