Skip to content

Instantly share code, notes, and snippets.

@poindextrose
Created January 22, 2015 16:49
Show Gist options
  • Save poindextrose/1581bd71751ae2be280b to your computer and use it in GitHub Desktop.
Save poindextrose/1581bd71751ae2be280b to your computer and use it in GitHub Desktop.
Change JDK version on OS X
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:?;;")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment