Skip to content

Instantly share code, notes, and snippets.

@jvwong
Last active June 22, 2016 10:18
Show Gist options
  • Save jvwong/37fb4c6632681e69b5f387971c180ec1 to your computer and use it in GitHub Desktop.
Save jvwong/37fb4c6632681e69b5f387971c180ec1 to your computer and use it in GitHub Desktop.
Switching Java on OSX

List the current installed Java versions

$ /usr/libexec/java_home -V

Install the version desired

Apple provides their own version of 6 (Java for OS X 2015-001)

List the current installed Java versions

You should see the version installed

Matching Java Virtual Machines (3):
    1.8.0_74, x86_64:	"Java SE 8"	/Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home
    1.6.0_65-b14-468, x86_64:	"Java SE 6"	/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    1.6.0_65-b14-468, i386:	"Java SE 6"	/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home  

Select the version

$ export JAVA_HOME=`/usr/libexec/java_home -v 1.6.0_65-b14-468`

Confirm the java version

$ export JAVA_HOME=`/usr/libexec/java_home -v 1.6.0_65-b14-468`
$ java -version
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment