[GRADLE-2545] Wrong JAVA_HOME setting Created: 03/Nov/12  Updated: 10/Feb/17  Resolved: 10/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-3
Fix Version/s: None

Type: Bug
Reporter: Vadym Assignee: Unassigned
Resolution: Won't Fix Votes: 0


After installing I got error

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.

But I have correct JAVA_HOME.
I went to /usr/bin/gradle and found some strange place

export JAVA_HOME=/usr/lib/jvm/default-java
export GRAILS_HOME=/usr/share/gradle

  1. Attempt to set JAVA_HOME if it's not already set.
    if [ -z "$JAVA_HOME" ] ; then

I think it is something wrong with first line.

Comment by Adam Murdoch [ 04/Nov/12 ]

There have been lots of fixes to the script since Gradle 1.0-milestone-3. Can you try a more recent version of Gradle and let us know if the problem still exists?

Comment by pinaki [ 26/Dec/13 ]

I have downloaded and extracted the gradle-1.9 and the java-1.7. The environment variable for java and gradle has been set too. But unfortunately me too getting the same error message. If needed more information please post it here.
OS: win7 x64
Java: 1.7 x64
Android Studio 0.4.0

Comment by fabio [ 16/May/14 ]

this error persists on ubuntu 14.04 x64.
I solved by simply editing the file "/usr/bin/gradle" and commenting the follow line:

before editing:


export JAVA_HOME=/usr/lib/jvm/default-java

after editing:


# export JAVA_HOME=/usr/lib/jvm/default-java

Other informations:

I'm not using OpenJDK7, but the Oracle-JDK7 installed as described in this link


dev@devworkstation:~$ gradle --version

Gradle 1.4

Gradle build time: Segunda-feira, 9 de Setembro de 2013 20h44min25s UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.3 compiled on April 8 2014
Ivy: non official version
JVM: 1.7.0_55 (Oracle Corporation 24.55-b03)
OS: Linux 3.13.0-24-generic amd64
Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Benjamin Muschko [ 10/Feb/17 ]

Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved.

Generated at Wed Jun 30 12:24:52 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.