Skip to content

Instantly share code, notes, and snippets.

@lance
Created March 15, 2012 22:04
Show Gist options
  • Save lance/2047280 to your computer and use it in GitHub Desktop.
Save lance/2047280 to your computer and use it in GitHub Desktop.
Java version switcher
# Props to qmx and abstractj for the inspiration
#
# Put this file in your home directory and these lines to .profile
# if [[ -f "$HOME/.java.env" ]]; then
# source "$HOME/.java.env";
# fi
VERSION=$1
if [ ! -n "$VERSION" ]
then
VERSION="1.6"
fi
echo "Using Java version $VERSION"
export JAVA_HOME=$(/usr/libexec/java_home -v $VERSION)
alias j7env="source ~/.java.env 1.7"
alias j6env="source ~/.java.env 1.6"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment