Skip to content

Instantly share code, notes, and snippets.

@gwpantazes
Last active June 5, 2020 15:27
Show Gist options
  • Save gwpantazes/d684aea459946f1bfa6efa25c85a9bab to your computer and use it in GitHub Desktop.
Save gwpantazes/d684aea459946f1bfa6efa25c85a9bab to your computer and use it in GitHub Desktop.
.bash_profile Java/jenv configuration which sets JAVA_HOME dynamically from jenv
# Java Configuration: jenv, JAVA_HOME, utilities and aliases, etc...
DEFAULT_JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home"
if which jenv > /dev/null
then
export JENV_ROOT="$HOME/.jenv"
export PATH="$JENV_ROOT/bin:$PATH"
# Enable shims and autocompletion.
# WARNING jenv init wipes out any previously set JAVA_HOME variable.
eval "$(jenv init -)"
export JAVA_HOME="$JENV_ROOT/versions/$(cat $JENV_ROOT/version)"
else
export JAVA_HOME="$DEFAULT_JAVA_HOME"
echo "WARNING: jenv cannot be found. Setting JAVA_HOME to the hard-coded default: $JAVA_HOME"
fi
alias keytool="$JAVA_HOME/bin/keytool"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment