Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while importing projects

Tags:

gradle

libgdx

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.

like image 263
raco Avatar asked Sep 01 '14 22:09

raco


People also ask

What does Import error mean?

The ImportError is raised when an import statement has trouble successfully importing the specified module. Typically, such a problem is due to an invalid or incorrect path, which will raise a ModuleNotFoundError in Python 3.6 and newer versions.


2 Answers

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.

like image 54
Alon Zilberman Avatar answered Sep 19 '22 14:09

Alon Zilberman


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.

like image 21
Jervisbay Avatar answered Sep 21 '22 14:09

Jervisbay