A few days back I was looking for a way to change the CurrentJDK symbolic link on my Mac. I had found this nice script somewhere (don’t quite remember where). But is is very useful.
#!/bin/sh cd /System/Library/Frameworks/JavaVM.framework/Versions CURJDK="`readlink CurrentJDK`"echo Current JDK version: $CURJDK if [ "$1" == "" ]; thenecho Installed versions:lsexitfi VERFOUND=`ls | grep $1 | head -n 1` if [ "$VERFOUND" != "$1" ]; thenBASE="`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 127fi echo You must now enter your Mac OS X password to change the JDK.sudo ln -fhsv $1 CurrentJDK
Save it as a file name of your choice. I saved it as “SetJDK.sh”. Give it execute permissions, and run the script.