0

I am trying to run a server that requires Java 7 using terminal. After installing Java 7, typing java -version in terminal still shows Java 6. Previously, I would use the Java Preferences application, but Apple has removed it. Does anyone have any idea how to change the Java version the system uses without the Java Preferences application? Or if anyone knows a download link for Java Preferences, that would be greatly appreciated as I am able to achieve the same results by just using that. Thank you so much!

I am using the latest version of Mac OS X

3
  • Type which java and see where it's loading Java from. Maybe you installed a separate copy somewhere and that's in your path.
    – Marvo
    Dec 24, 2012 at 0:59
  • Um, with Java Preferences you mean the Java Control Panel window you could once call from either Utilites or System Preferences? With 1.7 it's in System Preferences..
    – dbf
    Dec 24, 2012 at 1:17
  • Spotlight :) command-space then type java preferences, it has not been removed. Dec 24, 2012 at 1:30

2 Answers 2

0

http://www.adam-bien.com/roller/abien/entry/java_se_development_kit_7

export JAVA_HOME="/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home"

Try entering that line in terminal. You can also type- java -version to see which version is currently running.

I've had to do the exact opposite as you, revert to Java 1.6 after having 1.7 installed.

This is old but provides some background that may help lead you on the right path: https://blogs.oracle.com/bobby/entry/switching_jdks_on_mac

Just beware that this situation can be a bit of a head ache to solve...!

2
  • Alternatively to exporting JAVA_HOME, one may run sudo echo "/Library/Java/... path ..." > /etc/paths.d/jdk1.7.0_09
    – ignis
    Dec 24, 2012 at 1:27
  • In my case, the path ends with /bin (i.e. /Library/Java/JavaVirtualMachines/jdk1.7.0.jdk/Contents/Home/bin)
    – ignis
    Dec 24, 2012 at 1:28
0

You can have multiple versions of Java JDK installed at the same time. You can, then, set the version of the JDK to use within terminal. You can also set the version you want as the default in, ~/.bash_profile

export JAVA_HOME=`/usr/libexec/java_home -v '1.6*'`
export JAVA_HOME=`/usr/libexec/java_home -v '1.7*'`
export JAVA_HOME=`/usr/libexec/java_home -v '1.8*'`