Created
March 25, 2014 07:44
-
-
Save todesking/9756888 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 jvm() { | |
local cmd="$1" | |
local java_root="/Library/Java/JavaVirtualMachines/" | |
case "$cmd" in | |
list ) | |
find "$java_root" -maxdepth 1 | grep 'jdk.*\.jdk' | gsed 's/.*jdk\(.*\)\.jdk$/\1/' ;; | |
use ) | |
local version="$2" | |
local home="$java_root/jdk${version}.jdk/Contents/Home/" | |
if [ -d "$home" ]; then | |
export JAVA_HOME="$home" | |
echo "JAVA_HOME=$JAVA_HOME" | |
else | |
echo "Not found: $home" | |
return 1 | |
fi | |
;; | |
"" | "help") | |
echo "USAGE: $0 list|user <version>" ;; | |
* ) | |
echo "Unknown command: ${cmd}" | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment