Created
August 12, 2014 10:46
-
-
Save patforna/afcc627df7eb15e0ea9d 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
function addToPath() { | |
export PATH=$1:$PATH | |
} | |
function removeFromPath() { | |
export PATH=$(echo $PATH | sed -E -e "s;:$1;;" -e "s;$1:?;;") | |
} | |
# 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="$HOME/Dropbox/system/java/jdk$@/Contents/Home" | |
addToPath $JAVA_HOME/bin | |
fi | |
java -version 2>&1 | head -n 1 | |
} | |
# default to JDK 1.7 for new shells | |
jdk 1.7 > /dev/null | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment