I confess I am a desperate noob with both gradle and linux, but after having trouble getting gradle to run I discovered that the problem was the line
export JAVA_HOME=/usr/lib/jvm/default-java
in the gradle shell script (gradle 1.4)
This seems a bit presumptuous (my JDK installed to /usr/lib/jvm/java-7-oracle). Surely the script should presume the user sets their JAVA_HOME variable as they see fit, or at least check if its set, and if not then try a default value.
I’ve fixed it for now, but am I going to have to hack the script again when I update my Gradle version?
Gradle build time: Monday, 9 September 2013 20:44:25 o’clock UTC Groovy: 1.8.6 Ant: Apache Ant™ version 1.9.2 compiled on July 14 2013 Ivy: non official version JVM: 1.7.0_45 (Oracle Corporation 24.45-b08) OS: Linux 3.11.0-14-generic i386
I installed it using apt-get. Is that wrong? I now see on the Gradle website the latest install is 1.9
The offending code in the gradle script in more context:
...
CLASSPATH=$APP_HOME/lib/gradle-launcher-1.4.jar
#export JAVA_HOME=/usr/lib/jvm/default-java
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
...
Recent Grade versions don’t have this export statement. So either this was a problem with 1.4 that has meanwhile been fixed, or the export statement was added by another party (e.g. the party maintaining the apt package).