From 8142b27ee4d6e2602662608ca04d5a0bc04dd2d8 Mon Sep 17 00:00:00 2001 From: Will Moffat Date: Tue, 13 Apr 2010 22:14:02 +0000 Subject: [PATCH] Fixed: Mac OS X default to Java 5. export JAVA_HOME to Java 6 git-svn-id: http://google-refine.googlecode.com/svn/trunk@469 7d457c2a-affb-35e4-300a-418c747d4874 --- gridworks | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/gridworks b/gridworks index b1e4c44ac..ba634d6ec 100755 --- a/gridworks +++ b/gridworks @@ -625,24 +625,27 @@ load_configs gridworks.ini # ----- Make sure there is an appropriate java environment is available ------------- -JAVA=`which java` -if [ -z "$JAVA" ]; then - if [ "$JAVA_HOME" ]; then - JAVA="$JAVA_HOME/bin/java" - if [ ! -f "$JAVA" ] ; then - error "Could not find the 'java' executable at '$JAVA', are you sure your JAVA_HOME environment variable is pointing to a proper java installation?" +if [ "$SYSTEM" = 'Darwin' ] && [ -z "$JAVA_HOME" ]; then + # Mac OS X defaults to Java 5. So update JAVA_HOME unless the user manually set it. + export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home" + JAVA="$JAVA_HOME/bin/java" +else + JAVA=`which java` + if [ -z "$JAVA" ]; then + if [ "$JAVA_HOME" ]; then + JAVA="$JAVA_HOME/bin/java" + if [ ! -f "$JAVA" ] ; then + error "Could not find the 'java' executable at '$JAVA', are you sure your JAVA_HOME environment variable is pointing to a proper java installation?" + fi + else + error "The 'java' command should be in your path or the 'JAVA_HOME' environment variable should be set" fi - elif [ "$SYSTEM" = 'Darwin' ]; then - JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home" - JAVA="$JAVA_HOME/bin/java" - else - error "The 'java' command should be in your path or the 'JAVA_HOME' environment variable should be set" fi fi - + JAVA_VERSION=`$JAVA -version 2>&1 | grep version | cut -d ' ' -f 3 | egrep ^\"1\.6` if [ -z "$JAVA_VERSION" ]; then - error "Gridworks requires Java version 6 or later." + error "Gridworks requires Java version 6 or later. If you have multiple versions of Java installed, please set JAVA_HOME to the correct version." fi # ----- Parse the command line args ------------------------------------------