Skip to content

Instantly share code, notes, and snippets.

@uzzu
Created February 12, 2020 09:15
Show Gist options
  • Save uzzu/c9311e7b450ff539f501ed6af5fa3359 to your computer and use it in GitHub Desktop.
Save uzzu/c9311e7b450ff539f501ed6af5fa3359 to your computer and use it in GitHub Desktop.
function javaenv() {
local err specified
if [[ -z `echo $1` ]]; then
echo $JAVA_HOME
return
fi
err=`/usr/libexec/java_home -v $1 2>&1 >/dev/null`
if [[ -n $err ]] then
echo $err
return
fi
specified=`/usr/libexec/java_home -v $1`
echo "export JAVA_HOME=$specified"
export JAVA_HOME=$specified
export PATH=$JAVA_HOME/bin:$PATH
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment