Skip to content

Instantly share code, notes, and snippets.

@tachesimazzoca
Last active October 12, 2015 13:33
Show Gist options
  • Select an option

  • Save tachesimazzoca/09b981a1c5150fdb5634 to your computer and use it in GitHub Desktop.

Select an option

Save tachesimazzoca/09b981a1c5150fdb5634 to your computer and use it in GitHub Desktop.
JAVA_HOME on Mac OS X

JAVA_HOME on Mac OS X

# Listing installed JDK versions
% /usr/libexec/java_home -V
Matching Java Virtual Machines (4):
    1.8.0_60, x86_64:	"Java SE 8"	/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
    1.7.0_45, x86_64:	"Java SE 7"	/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
    1.6.0_65-b14-462, x86_64:	"Java SE 6"	/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    1.6.0_65-b14-462, i386:	"Java SE 6"	/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home

# Display a path to the specified JDK version
% /usr/libexec/java_home -v 1.7.0_45
/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home

# Set JAVA_HOME using the java_home command
% vi ~/.bash_profile
...
# Default JDK version
export JAVA_HOME=`/usr/libexec/java_home -v 1.7.0_45`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment