14

While importing projects into eclipse i have this error:

Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory. Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.11-all.zip'.

As I have checked i need to set JAVA_HOME (i have the JDK on my computer), but i dont have a clue how to do that.

raco
  • 398
  • 1
  • 5
  • 18
  • Try adding the %JAVA_HOME%/bin directory into PATH system variable – sergiomse Sep 01 '14 at 22:55
  • task is done. i have edit path to C:\Program Files (x86)\Java\jdk1.8.0_20\bin, but error still persists – raco Sep 01 '14 at 23:36
  • well i have managed to do something with this video: https://www.youtube.com/watch?v=Atu3ce2-dYg just that i cant manage to get last part in cmd to work, but if i write just javac it recognizes it – raco Sep 01 '14 at 23:53
  • The path is C:\Program Files (x86)\Java\jdk1.8.0_20 not C:\Program Files (x86)\Java\jdk1.8.0_20\bin- Check my answer below – Prasanth Louis Aug 23 '15 at 20:10

3 Answers3

33

I had lots of similar problems and I think that the best solution is to specify JDK location manually. In order to do it:

Add two files to project root folder gradle.properties:

org.gradle.java.home=C:/Program Files/Java/jdk1.7.0_03

and local.properties:

org.gradle.java.home=C:/Program Files/Java/jdk1.7.0_03

You should change org.gradle.java.home value to JDK path in your system. If you will have the same problem with android SDK add sdk.dir=/Users/alonzilberman/Android/adt-bundle-mac-x86_64-20130917/sdk to your local.properties.

After adding files refresh gradle build.

Alon Zilberman
  • 2,120
  • 1
  • 16
  • 16
  • 3
    here is some easier way http://stackoverflow.com/questions/16913397/when-i-am-running-gradle-project-via-eclipse-i-got-some-exception – Yar Dec 31 '14 at 05:16
  • For me just updating the gradle.properties file worked. Also, this file is present by default in gradle project's root dir. – EMM Feb 26 '15 at 16:58
1

I got the same message while trying to build a project in Android Studio. After hours of research, trying different versions of JDK (from 8 to 6) I found this answer that fixed my problem: https://discuss.gradle.org/t/mac-gradle-issues-with-finding-using-jdk-7-the-usual-answers-to-this-question-arent-working-expert-required/2553/24

The reason was that the AUSKey package installed a tools.jar in /Library/Java/Extensions directory that derailed Gradle looking for the compiler. Removing that file fixed the problem and I can now build in Android Studio.

Jervisbay
  • 149
  • 1
  • 1
  • 6
1

Create a new system variable called JAVA_HOME and add

C:\Program Files\Java\jdk1.8.0_25

It's because your environment variable isn't pointing to your jdk folder. Don't point it to your bin folder.

Prasanth Louis
  • 4,658
  • 2
  • 34
  • 47