It’s already been while since Apple removed the “Java Preference Pane” from OS X, with which it was possible to change between various installed Java versions. I shortly needed to compile some old Java application against the JDK version 1.6 and I was questioning how to change the compiler version.
export JAVA_HOME=`/usr/libexec/java_home -v 1.6`
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
Then you can query the currently active version by issuing
java -version or
java -version java version "1.6.0_65" Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716) Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode) javac -version javac 1.6.0_65
If you want those changed to be persistent, don’t forget to add the
export statement to your
I run this site without advertisement of any kind. All information is free and my only goal is to give back something to the amazing free software development community. If you find some value in this, please consider donating me a cup of coffee using PayPal. Thank you so much!