Installed Java 7 on Mac OS X but Terminal is still using version 6 Installed Java 7 on Mac OS X but Terminal is still using version 6 java java

Installed Java 7 on Mac OS X but Terminal is still using version 6


Oracle's installer puts java inside the /Library/Internet Plug-Ins/JavaAppletPlugin.plugin. And it doesn't overwrite /usr/bin/java. So, if you issue a

whereis java

in the terminal, it'll return /usr/bin/java. (which in turn points to /System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java, which is Apple's 1.6 version).

So, if you want to use the new java version, replace the /usr/bin/java symlink so that it points to /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java instead:

sudo rm /usr/bin/javasudo ln -s /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java /usr/bin


Install the JDK 7 and this problem will solve itself.

Be sure to get the Java Development Kit (JDK) which includes compilers and stuff like that, rather than just the Java Runtime Environment (JRE) .


vi ~/.bash_profile

add

export JAVA_HOME=`/usr/libexec/java_home -v 1.7`

This tells your /usr/bin/java link target to use the latest Java 7 Package installed in

/Library/Java/JavaVirtualMachines/

So for JDK 1.7.0_17 JAVA_HOME would be:

/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home

Note: There were a lot of change in this area recently to move Mac OS X from Appels own System integrated Java packages to Oracle based Java Packages. The above solution is working fine as of Mac OS X 10.8.2