Last active
August 29, 2015 14:08
-
-
Save NeQuissimus/7971c8b154bda6d4a504 to your computer and use it in GitHub Desktop.
Switch JDK versions on OSX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original from http://www.jayway.com/2014/01/15/how-to-switch-jdk-version-on-mac-os-x-maverick/ | |
function setjdk() { | |
if [ $# -ne 0 ]; then | |
removeFromPath '/System/Library/Frameworks/JavaVM.framework/Home/bin' | |
if [ -n "${JAVA_HOME+x}" ]; then | |
removeFromPath $JAVA_HOME | |
fi | |
export JAVA_HOME=`/usr/libexec/java_home -v $@` | |
export PATH=$JAVA_HOME/bin:$PATH | |
fi | |
} | |
function removeFromPath() { | |
export PATH="$(echo "$PATH" | sed -E -e "s;:$1;;" -e "s;$1:?;;")" | |
} | |
setjdk 1.9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment