I spend a lot of time bouncing between different versions of JDKs and different versions of Grails. To make my life easier, I’ve got these files in my bin directory.
setJDK
#!/bin/sh 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 ln -fhsv $1 CurrentJDK sudo ln -fhsv $1 Current
I found that setJDK code somewhere on the internet, but I’m not really sure where and I had trouble finding it again. So I thought I’d share it here.
To integrate SoyLatte Java (which you probably want to be using anyway), just create a symlink in /System/Library/Frameworks/JavaVM.framework/Versions that points to your SoyLatte install.
setGrails
I’ve modified that script a bit to allow me to modify the version of Grails to use. This script assumes that you have your Grails distributions stored in BINDIR, and you’ve added $BINDIR/grails/bin to PATH. Once that’s set up, this script works like a charm:
#!/bin/sh cd $BINDIR CURGRAILS="`readlink grails`" echo Current Grails version: $CURGRAILS if [ "$1" == "" ]; then echo Installed versions: echo `ls -1 | grep "grails-"` exit fi VERFOUND=`ls -1 | grep $1 | head -n 1` if [ "$VERFOUND" != "grails-$1" ]; then BASE="`basename $0`" echo Error: Could not change Grails-- version $1 not installed! echo Run $BASE without arguments to see a list of installed versions. exit 127 fi ln -fhsv "grails-$1" grails
Finger-Saving Tips
If you’re really hardcore, add these lines to ~/.profile:
alias sg=setGrails alias sj=setJDK
No related posts.