Skip to content

Instantly share code, notes, and snippets.

@jasonm
Created April 10, 2009 04:37
Show Gist options
  • Save jasonm/92937 to your computer and use it in GitHub Desktop.
Save jasonm/92937 to your computer and use it in GitHub Desktop.
#!/bin/sh
# originally from http://www.macosxhints.com/article.php?story=20060121171126988
# note that the last four lines were modified from the original;
# I also updated the Current alias (since my /usr/bin/java* are symlinked through that)
# and I added the rm and removed the -h option from ln
cd /System/Library/Frameworks/JavaVM.framework/Versions
CURJDK="`readlink CurrentJDK`"
echo Current JDK version: $CURJDK
if [ "$1" == "" ]; then
echo Installed versions:
ls
exit
fi
VERFOUND=`ls | grep $1 | head -n 1`
if [ "$VERFOUND" != "$1" ]; then
BASE="`basename $0`"
echo Error: Could not change JDK-- version $1 not installed!
echo Run $BASE without arguments to see a list of installed versions.
exit 127
fi
echo You must now enter your Mac OS X password to change the JDK.
sudo rm Current
sudo rm CurrentJDK
sudo ln -fsv $1 Current
sudo ln -fsv $1 CurrentJDK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment