Create a gist now

Instantly share code, notes, and snippets.

@johan /index.md
Last active Jun 8, 2018

Embed
What would you like to do?
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.

@jakegub

This comment has been minimized.

Show comment
Hide comment
@jakegub

jakegub Apr 30, 2014

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

jakegub commented Apr 30, 2014

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

@jbyler

This comment has been minimized.

Show comment
Hide comment
@jbyler

jbyler 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.

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.

@ncarchedi

This comment has been minimized.

Show comment
Hide comment
@ncarchedi

ncarchedi Jul 28, 2014

Worked as advertised on OS X 10.9.4. Thanks!

ncarchedi commented Jul 28, 2014

Worked as advertised on OS X 10.9.4. Thanks!

@corbindavenport

This comment has been minimized.

Show comment
Hide comment
@corbindavenport

corbindavenport Jul 31, 2014

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

corbindavenport commented Jul 31, 2014

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

@muzll0dr

This comment has been minimized.

Show comment
Hide comment
@muzll0dr

muzll0dr Aug 8, 2014

Brilliant, thank you.

muzll0dr commented Aug 8, 2014

Brilliant, thank you.

@MauricioRoman

This comment has been minimized.

Show comment
Hide comment
@MauricioRoman

MauricioRoman Aug 24, 2014

Thank you, it worked perfectly!

MauricioRoman commented Aug 24, 2014

Thank you, it worked perfectly!

@Tokuriku

This comment has been minimized.

Show comment
Hide comment
@Tokuriku

Tokuriku Aug 30, 2014

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

Tokuriku commented Aug 30, 2014

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

@mobime

This comment has been minimized.

Show comment
Hide comment
@mobime

mobime Nov 12, 2014

You Sir, are an officer and a gentleman.

mobime commented Nov 12, 2014

You Sir, are an officer and a gentleman.

@michaelprflores

This comment has been minimized.

Show comment
Hide comment
@michaelprflores

michaelprflores Mar 20, 2015

This worked for me as well! Thanks very much!

michaelprflores commented Mar 20, 2015

This worked for me as well! Thanks very much!

@Zorrothefox

This comment has been minimized.

Show comment
Hide comment
@Zorrothefox

Zorrothefox Mar 21, 2015

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

Zorrothefox commented Mar 21, 2015

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

@lbaehren

This comment has been minimized.

Show comment
Hide comment
@lbaehren

lbaehren Jun 16, 2015

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

lbaehren commented Jun 16, 2015

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

@jgorecki

This comment has been minimized.

Show comment
Hide comment
@jgorecki

jgorecki Jul 30, 2015

fantastic -- this worked for me.

jgorecki commented Jul 30, 2015

fantastic -- this worked for me.

@haqueabida

This comment has been minimized.

Show comment
Hide comment
@haqueabida

haqueabida Sep 18, 2015

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.

haqueabida commented Sep 18, 2015

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.

@kdipietro

This comment has been minimized.

Show comment
Hide comment
@kdipietro

kdipietro Nov 4, 2015

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.

kdipietro commented Nov 4, 2015

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.

@aditinabar

This comment has been minimized.

Show comment
Hide comment
@aditinabar

aditinabar Feb 1, 2016

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

aditinabar commented Feb 1, 2016

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

@amactus

This comment has been minimized.

Show comment
Hide comment
@amactus

amactus 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?

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

This comment has been minimized.

Show comment
Hide comment
@josephspurrier

josephspurrier 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

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

This comment has been minimized.

Show comment
Hide comment
@ios122

ios122 Oct 27, 2016

直接安装对应版本的JDK,而不是安装JRE,是最简单的解决这个问题的方式.
Directly install the corresponding version of the JDK, rather than the installation of JRE, is the most simple way to solve this problem.

ios122 commented Oct 27, 2016

直接安装对应版本的JDK,而不是安装JRE,是最简单的解决这个问题的方式.
Directly install the corresponding version of the JDK, rather than the installation of JRE, is the most simple way to solve this problem.

@xXflyingpugXx

This comment has been minimized.

Show comment
Hide comment
@xXflyingpugXx

xXflyingpugXx Dec 9, 2016

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!!!!!!!

xXflyingpugXx commented Dec 9, 2016

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