6

I tried to install Java 7 Update 51.pkg, downloaded from here (http://java.com/en/download/mac_download.jsp?locale-=en), following the instructions here (http://java.com/en/download/help/mac_install.xml).

After the installation, in terminal, issuing java -version reports:

TimsMacBookAir:compiler-latest tim$ 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)

I tried using java_home to report the installed versions:

TimsMacBookAir:~ tim$ /usr/libexec/java_home -v 1.7 --exec javac -version
Unable to find any JVMs matching version "1.7".
javac 1.6.0_65
TimsMacBookAir:~ tim$ /usr/libexec/java_home -v 1 --exec javac -version
javac 1.6.0_65

I tried running the java package multiple times, rebooting, etc.

Even after installing with apparent success, /System/Library/Frameworks/JavaVM.framework/Versions/ does NOT list java 1.7 being installed, and as such I can't use https://stackoverflow.com/questions/12757558/installed-java-7-on-mac-os-x-but-terminal-is-still-using-version-6.

I am trying to run java at the command line. I don't need to use java in browsers, nor care if it works in browsers or not. I also cannot find the "java preferences" control panel / applet anywhere.

3 Answers 3

10

Yeah - this is a huge f**g hairball, thanks mostly to Apple for their blockheaded resistance to supporting their users. There are some links that seem to allow one to manage their situation. I currently use Mavericks 10.9.4. Here's my take on the way to proceed:

DISCLAIMER: I am not expert on OSX, nor with Java, so follow these instructions with care. All I can say is that they semmed to work for me.

First, know that installing the latest version of Java (the JRE) gets the latest software on your system, but your system doesn't necessarily use it! To do that, you'll need to make use of the command line. Here's what I did:

First, I installed the latest version of Java, as downloaded from Oracle's Java website. To see if the new version was 'registered' in OSX, use the following command. This result shows that the 'system' doesn't recognize the upgrade, and won't be using it.

MacBook-1:~ jmoore$ 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)

After some research, the solution seems to be the following:

MacBook-1:~ jmoore$ export JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home" 

Now, let's check the version again to see if we've made any progress:

MacBook-1:~ jmoore$ java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode) 

OK! I think that's it.

1
  • I think the bit that throws me is export JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home", since I want Java 7 x64 to run jar files at the OS level using a shell script, and it has nothing to do with the internet or a browser... why registering an "internet plug-in" fixes this is beyond me (well, telling java to use the plugin version), but Apple have some very strange conventions.
    – frumbert
    Jul 6, 2014 at 23:27
3

James Moore's answer is the right one. Regarding you latest comment, you can edit .bash_profile like this :

vi ~/.bash_profile

and add a line :

export JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"

After that, make sure you save your file, and close (really close) your terminal before re-launching it, and the result will be ok.

0

That didn't work for me. The way I did it was creating a soft link:

MBP:bin awesome_nuts$ which java
/usr/bin/java

MBP:bin awesome_nuts$ sudo ln -s /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java /usr/bin/java
MBP:bin awesome_nuts$ java -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .