-
-
Save matthewadams/5760495 to your computer and use it in GitHub Desktop.
Easy JVM switcher script for Mac OS X
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
#!/bin/bash | |
if [ ! $1 ]; then | |
echo "Please include desired jdk version: 1.7 or 7, 1.6 or 6, ..." | |
exit | |
fi | |
j7="/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home" | |
#j6="/Library/Java/JavaVirtualMachines/1.6.0_45-b06-451.jdk/Contents/Home" | |
j6="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home" | |
case $1 in | |
"1.7" | "7") export JAVA_HOME=$j7 ;; | |
"1.6" | "6") export JAVA_HOME=$j6 ;; | |
*) | |
echo "Supported versions are 1.6, 6, 1.7, or 7" | |
exit | |
;; | |
esac | |
# scrub path of any JAVA_HOMEs | |
for j in "$j7" "$j6" | |
do | |
PATH=`echo $PATH | sed s,"$j/bin",,g` | |
done | |
if [ "$2" == "all" ]; then | |
# replace for entire machine by replacing symlink | |
rm ~/.java | |
ln -s $JAVA_HOME ~/.java | |
else | |
# replace for just this shell by prepending java to scrubbed path | |
export PATH=$JAVA_HOME/bin:$PATH | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment