When trying to run gradle, I get the following error:
# gradle
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/default-java
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
However, when I check the JAVA_HOME variable I get:
# echo $JAVA_HOME
/usr/lib/jvm/java-7-oracle
My JAVA_HOME is defined in .bashrc and I have double checked that it is set as the source.
Running java -version
also confirms that JAVA_HOME is set correctly and is on the PATH.
# java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
I have also checked that /usr/bin/java
symlinks to /etc/alternatives/java
which in turn correctly symlinks to /usr/lib/jvm/java-7-oracle/jre/bin/java
Additionally I've checked that there are no duplicate JAVA_HOME definitions in .bash_profile
or /etc/profile
.
So my question is how/why does Gradle find /usr/lib/jvm/default-java
, and more importantly how do I point it to the correct directory?
Other programs which require the JDK work fine, so I think its a Gradle issue. I've also tried reinstalling Gradle which made no difference.
I'm running 64bit Xubuntu (Ubuntu 13.10 base)
/usr/lib/jvm/default-java
directory or symlink? And how did you install Gradle? – Peter Niederwieser/usr/lib/jvm/default-java
dir. Installed with apt (apt-get install gradle) – James BarnettJAVA_HOME
to be set. IfJAVA_HOME
is set, the script uses$JAVA_HOME/bin/java
to run Gradle. Otherwise, it usesjava
(i.e.java
has to be on thePATH
). Perhaps the (third-party) apt package uses a modified start script. – Peter Niederwieserusr/lib/jvm/defult-java
. Thanks for the help – James Barnettsource ~/.bashrc
, or reboot your machine after setting JAVA_HOME? – IgorGanapolsky