Skip to content

Instantly share code, notes, and snippets.

@stephenpatten
Forked from lance/.java.env.sh
Created June 15, 2018 04:22
Show Gist options
  • Save stephenpatten/86bde3afe3ee52d1306b9c0d27543576 to your computer and use it in GitHub Desktop.
Save stephenpatten/86bde3afe3ee52d1306b9c0d27543576 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