Last Updated: November 21, 2017
· gamussa

Set default JDK on Mac OS X

Apple announced to remove Java Preferences app from Mac OS X 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


1 Response
Add your response


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

over 1 year ago ·