Bash Script for setting JAVA_HOME on Linux & OSX

[bash]
jvmVer=java -version 2>&1 | grep "java version" | awk '{print $3}' | tr -d \"
rc=$?
if [ ! "$rc" == "0" ]; then
echo " "
echo "ERROR: JDK does not appear to be installed."
exit 3
fi

if [ "x$JAVA_HOME" == "x" ]; then
osName=uname
if [ "$osName" == "Darwin" ]; then
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
else
JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-amd64
fi
fi
[/bash]