Running Gradle project via Eclipse errors "system Cannot find System Java Compiler"
Asked Answered
F

12

40

When I run Gradle project via Eclipse I get below error.

system 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 installation 'C:\gradle-1.2-all\gradle-1.2'.

But I have installed JDK 1.7 and set the JAVA_HOME environment variable.

Forwhy answered 4/6, 2013 at 8:46 Comment(0)
V
62

Go to File -> Other Settings -> Default Project Structure

enter image description here

Now Set your JDK location

enter image description here

Voluptuous answered 3/8, 2016 at 6:4 Comment(1)
@cyberPrivacy for "eclipse" user follow this https://mcmap.net/q/389469/-running-gradle-project-via-eclipse-errors-quot-system-cannot-find-system-java-compiler-quotVoluptuous
D
52

In Preference of Eclipse (main menu: Window -> Preferences), select

Gradle -> Arguments -> Java Home, select "Workspace JRE".

Then select one of your jdk in your workspace.

On my laptop it's "jdk1.6.0_45". Yours should be the JDK 1.7 home folder, something like "/usr/lib/jvm/java-7-openjdk-amd64/".

Downandout answered 11/8, 2014 at 9:19 Comment(2)
Thanks, I was having the exact same problem after creating a new workspace and getting started with Gradle. I just had to setup my JDK in eclipse, and follow your instructions above.Edlun
Hi, Am not sure why I am not getting Arguments option in Gradle - eclipse - window - preferences.Roofer
G
15

You can face this problem even when all your system variables are set and correct. Usually this happens when you work with foreign code from Github etc.

So what you have to do is to check gradle version in your project level build.gradle file, and if it doesn't match to current installed version, update it.

buildscript {
    //other setupps
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0' //update this to your current version
    }
}
Groyne answered 20/2, 2017 at 11:5 Comment(1)
Thanks so much. I tried everything related to environmental variables and jdk versions, and this was the issue all along. Wrong gradle version. Worst error message ever.Raab
S
13

In Gradle Task View -> build -> right click->Open Gradle Configuration -> JAVA_HOME -> and put the current value of your enviroment, something like C:\Program Files\Java\jdk1.7.0_79

I hope this help you

Southwestwards answered 28/11, 2015 at 0:56 Comment(0)
H
4

I tried following, but in Eclipse (luna), Run as, "gradle build Gradle build", still failed.

  1. change JAVA_HOME

  2. Preference, Gradle -> Arguments -> Java Home, select "Workspace JRE".

Solution: Go command line, run gradle build as answered by user3754672, then back to Eclipse, all working.

Hidebound answered 4/6, 2015 at 15:19 Comment(0)
B
3

It's likely you haven't installed a JDK. Even though you have "jdk1.7", you may have only the runtime environment. You may need to install the "-devel" option for the package, for example, both these would be required:

  • java-1.7.0-openjdk
  • java-1.7.0-openjdk-devel

If you can't find the right package, tell us your distro and the exact name of the jdk1.7 package you have so we can help more.

Bascule answered 5/9, 2013 at 4:39 Comment(0)
F
3

Although you may have a full JDK installed somewhere, and pointed to by JAVA_HOME, I don't think the Eclipse Gradle plugin will use it by default. I ran into the same problem running the the "test" target for the Gradle "quickstart" app in Springsource Groovy/Grails Tool Suite 3.3.0(Gradle IDE 3.3.0.201307040643 plugin).

If you re-run the failed Gradle target from the "External Tools" menu (under the "arrow with a suitcase icon"), adding "--debug" in the "Program Args" under the Arguments tab, it will show you in the console what JVM/JDK it uses. I was able to get around the problem by deselecting "Use Gradle wrapper's default" in the Java Home section of the Arguments tab, and replacing it with an Execution Environment setting that pointed to my 1.7 JDK that I had installed. I'm sure there's a way to have it do this by default, so you don't have to configure each targets run configuration, but this method should fix the immediate problem.

Flews answered 28/9, 2013 at 15:51 Comment(0)
C
3

I think the wrapped gradle uses the same java as eclipse. Since Eclipse seems to use jre by default you can get the issue mentioned in the question. Try this: Go to your eclipse.ini and add -vm argument like this:

-vm
c:/java/jdk1.8/javaw.exe
Colvin answered 26/5, 2016 at 8:51 Comment(0)
B
2

Issue

Using the Eclipse -> gradle -> select task to execute and error "...cannot find system java compiler."

Solution

Go to the path where your build.gradle path is... and using the cmd manually type gradle build <- this will work.

Done.

Back to Eclipse and execute the gradle task. It will work again!

Baisden answered 25/11, 2014 at 8:59 Comment(2)
doesn't this defeat some of the purpose of using the ide to being with? It worked for me also, but isn't the desired total solution.Convection
This post gave me the indication that my Eclipse is mis-configured.Malchy
D
2

Change your gradle to min: classpath 'com.android.tools.build:gradle:2.0.0'and then Android Studio will ask you to update it. You will make and update of gradle and after that it will work.That is how I fixed it for me.

Dolli answered 19/11, 2016 at 1:23 Comment(0)
B
0

I deleted some old jdk's and encountered the same issue. None of the above outdated solutions worked. Gradle in its infinite wisdom stores the JDK location in C:\Users\User.gradle\gradle.properties. This property is not accessible via the IDE as far as I know.

Bennettbenni answered 13/3, 2018 at 9:12 Comment(0)
B
0

My Eclipse version: Eclipse Java EE IDE for Web Developers. Version: Photon Release (4.8.0)

Right click 'gradle.build' and then choose 'run as' -> 'Run Configurations'. In the left, choose 'gradle.build' under 'Gradle Project'. In the right, you could see something like 'Gradle Tasks', 'Project Settings', 'Java Home' and so on. Choose 'Java Home', you will see there is an input box. Put your JDK path there. (something like: C:\Program Files\Java\jdk-10) And then run.

Belsky answered 5/9, 2018 at 12:57 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.