From 0380b3bb76d95cbaad7551962f826d899aa6f618 Mon Sep 17 00:00:00 2001 From: Thorben Date: Wed, 6 Aug 2014 17:18:44 +0200 Subject: [PATCH] switch and list jdk functions --- plugins/java/java.plugin.zsh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 plugins/java/java.plugin.zsh diff --git a/plugins/java/java.plugin.zsh b/plugins/java/java.plugin.zsh new file mode 100644 index 00000000..570a0364 --- /dev/null +++ b/plugins/java/java.plugin.zsh @@ -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" \ No newline at end of file