-
-
Save patforna/e396d982ae90659444ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# switch between different jdk versions. usage: jdk 1.7 | |
function jdk() { | |
if [ $# -ne 0 ]; then | |
if [ -n "${JAVA_HOME+x}" ]; then | |
removeFromPath $JAVA_HOME | |
fi | |
export JAVA_HOME="/opt/java/jdk-$@" | |
export PATH=$JAVA_HOME/bin:$PATH | |
fi | |
echo JAVA_HOME set to $JAVA_HOME | |
java -version | |
} | |
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