switch and list jdk functions

This commit is contained in:
Thorben 2014-08-06 17:18:44 +02:00
parent 1b7a3ea99a
commit 0380b3bb76

View File

@ -0,0 +1,25 @@
function setjdk() {
if [ $# -ne 0 ]; then
removeFromPath '/System/Library/Frameworks/JavaVM.framework/Home/bin'
if [ -n "${JAVA_HOME+x}" ]; then
removeFromPath $JAVA_HOME
fi
export JAVA_HOME=`/usr/libexec/java_home -v $@`
export PATH=$JAVA_HOME/bin:$PATH
echo "JAVA_HOME = $JAVA_HOME"
java -version
fi
}
function removeFromPath() {
export PATH=$(echo $PATH | sed -E -e "s;:$1;;" -e "s;$1:?;;")
}
function listjdk() {
/usr/libexec/java_home -V
}
alias jdk="listjdk"
alias jdk6="setjdk 1.6"
alias jdk7="setjdk 1.7"
alias jdk8="setjdk 1.8"