When I import Java Gradle project to Eclipse, I can't see screen asking for JDK folder

There are several things going wrong and I don’t know how to resolve it.

I have two JDKs one is in C:\Program Files\java\jdk1.8, and another one is in C:\IBM\WAS80\java and I have defined a JAVA_HOME to point to C:\IBM\WAS80\java.

  1. when I import the java gradle project to eclipse ( I installed the buildship 2.0 to the Eclipse), I was given a screen asking for Gradle folder, and I have typed in the location of Gradle 2.14.1. On the same screen I was supposed to see an advanced options which ask me to type in the JDK location, but I don’t see anywhere to ask for this. This is the first question: why I am not shown a text box for me to type in the JDK location?

  2. then in my “Gradle Tasks” view I clicked on “war” under build, the build was successful and when I see the log in the console, the JDK location is always “C:\Program Files\java\jdk1.8”, which I should make the gradle build pointing to C:\IBM\WAS80\java?

Any help?

The option to specify a JDK location in the advanced options was only available in Buildship 1.x. It was removed in Buildship 2.x with the expectation that you will use the standard org.gradle.java.home property to set your JDK/JRE as that will cause both command line and Buildship to function the same. Details of this property are in the User Guide in the Build Environment section.

Thanks James. I am constructing a gradle.properties file and the content is simply:

org.gradle.java.home=C:\IBM\WAS80\java

But I get an error when importing the project.
Caused by: org.gradle.api.GradleException: Java home supplied via ‘org.gradle.java.home’ is invalid. Invalid directory: C:IBMWAS80java

I don’t know the syntax. I am using Gradle 2.14.1

The gradle.properties file is a standard [Java properties file] (http://docs.oracle.com/javase/8/docs/api/java/util/Properties.html#load(java.io.Reader)), so backslashes need to be escaped.

Thank you James.

yes I did escape them but simply it didn’t work. Can you simply give one example? I also found all the gradle doc just tell you how to do, never give an example, but I think the exampe is the most easy way to let people learn its syntax.

org.gradle.java.home=c:\IBM\WAS80\java

in my gradle.properties I have tried many combinations like this

org.gradle.java.home=c:\IBM\WAS80\java

or org.gradle.java.home=c:\IBM\WAS80\java

or org.gradle.java.home=c:/IBM/WAS80/\java

however none of them works

If you want to use the backslashes, you need to escape the backslashes and only the backslashes:

org.gradle.java.home=c:\\IBM\\WAS80\\java

You can also just use forward slashes like the non-Windows platforms use:

org.gradle.java.home=c:/IBM/WAS80/java

James, it works now using your syntax. I thought I tried those but it could be that I made a little mistake.

Anyway, Thanks a lot for the help. It is really appreciated!

the last confusion, in this discussion though, is, why the gradle import and gradle build in the eclipse gui doesn’t take my environment variable definition of JAVA_HOME in the windows system setting? However if I run “gradlew clean build” in the CLI, gradew does pull the value from JAVA_HOME in the windows system setting?

That’s because Eclipse doesn’t use JAVA_HOME, but instead uses the path specified in eclipse.ini. There is a longstanding feature request to improve that.

Many Thanks! You are so helpful,