Skip to content

Instantly share code, notes, and snippets.

@johan
Last active September 26, 2023 16:35
Show Gist options
  • Star 45 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save johan/10590467 to your computer and use it in GitHub Desktop.
Save johan/10590467 to your computer and use it in GitHub Desktop.
osx + java 7 = painfully easy

Step 1

Does your osx terminal speak java 7? Start Terminal.app 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 http://www.java.com/en/download/help/mac_install.xml 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 site:oracle.com 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:

oracle-miniboss

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 @mailinator.com and then head over to mailinator.com 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.

@marcstreeter
Copy link

@deponeWD I did exactly what you recommended. I'm on Catalina. I had to do source ~/.zshrc and it then recognized the change. Awesome thank you!

@enkash
Copy link

enkash commented Nov 20, 2020

@timur-tabi System Integrity Protection (SIP) is preventing you to alter usr/bin/java

Try to create a symlink of the same name under usr/local/bin --> sudo ln -s '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java' /usr/local/bin/java, open a new terminal window and see if your JDK is recognized with java - version.

This did work for me. It seems a safer solution than disabling "System Integration Protection (SIP/rootless)", for those who don't know much, like myself.

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