Skip to content


GRAILS-7217 Auto discover of JAVA_HOME #44

wants to merge 1 commit into from

3 participants


GRAILS-7217 I have extracted code that guesses JAVA_HOME from Groovy project and added it to startGrails script

grails member

Which unix environments (other than Mac OS X) has this been tested on?


I have personally tested it on Ubuntu 10.10 and Debian Squeeze (and it works). I assume that it was tested on more environments by folks from Groovy project

grails member

Closing outdated pull requests.

@lhotari lhotari closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 18, 2011
  1. GRAILS-7217 Auto discover JAVA_HOME

    Maciej Mazur committed
Showing with 12 additions and 0 deletions.
  1. +12 −0 bin/startGrails
12 bin/startGrails
@@ -68,6 +68,18 @@ if [ -z "$JAVA_HOME" ]; then
[ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] &&
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
+ else
+ javaExecutable="`which javac`"
+ [ -z "$javaExecutable" -o "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ] && die "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME."
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=`which readlink`
+ [ `expr "$readLink" : '\([^ ]*\)'` = "no" ] && die "JAVA_HOME not set and readlink not available, please set JAVA_HOME."
+ javaExecutable="`readlink -f \"$javaExecutable\"`"
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+ JAVA_HOME="$javaHome"
+ export JAVA_HOME
Something went wrong with that request. Please try again.