esa4sg
Last Updated: February 25, 2016
·
11.2K
· gamussa
0680be1c881abcf19219f09f1e8cf140

Set default JDK on Mac OS X

Apple announced to remove Java Preferences app from Mac OS X http://support.apple.com/kb/HT5493. Let's try to fix it. Generally, java applications will use the JAVA_HOME environment variable to pick a JDK.

To set to JDK 6

export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)

To set JDK 7

export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)

To set JDK 8

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

Created aliases for my zsh

alias setjdk16='export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)'
alias setjdk17='export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)'
alias setjdk18='export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)'

For exotic cases, like Netbeans follow instruction here https://blogs.oracle.com/bobby/entry/switching_jdks_on_mac

--
Cheers
Vik

Say Thanks
Respond

1 Response
Add your response

7988
8407b8ef6d5e1df77cb0a453e02a48d1

Thank you for the article, it helped me a lot.

over 1 year ago ·