Thursday, May 21, 2015

Set alias options to dynamically change JAVA_HOME to particular JDK in Mac OSX (Yosemite)

Add the following to ~/.zshrc  or ~/.bashrc:

#Set alias options to dynamically change JAVA_HOME to particular JDK
alias jdk16 = ' export JAVA_HOME=$(/usr/libexec/java_home -v 1.6) '
alias jdk17 = ' export JAVA_HOME=$(/usr/libexec/java_home -v 1.7) '
alias jdk18 = ' export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) '



Re-source the rc file to pickup changes on the terminal:
$source ~/.zshrc or ~/.bashrc



Sourced from:
http://apple.stackexchange.com/questions/135058/i-installed-oracle-java-jdk-8-but-java-command-line-is-still-reporting-it-is-ver

No comments:

Post a Comment