# Specifying JRE in Eclipse using Buildship does not work

**URL:** https://discuss.gradle.org/t/specifying-jre-in-eclipse-using-buildship-does-not-work/21474
**Category:** Help/Discuss
**Tags:** buildship, eclipse
**Created:** [February 6, 2017, 2:17pm UTC](https://discuss.gradle.org/t/specifying-jre-in-eclipse-using-buildship-does-not-work/21474 "2017-02-06T14:17:41Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![martin-linha](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@martin-linha](https://discuss.gradle.org/u/martin-linha)
#### Post date: [February 6, 2017, 2:17pm UTC](https://discuss.gradle.org/t/specifying-jre-in-eclipse-using-buildship-does-not-work/21474/1 "2017-02-06T14:17:41Z")

</div>

Hi

I have a simple Gradle project in Eclipse and using Buildship.

Inside build.gradle I print out java version like this

`println System.getProperty('java.home')`

In Eclipse, I have only one JRE in Installed JREs (that points to C:/Java/JDK8). JavaSE-1.8 in Execution Environments has only a single compatible JRE - the one pointing to C:/Java/JDK8. My JAVA\_HOME also points to C:/Java/JDK8.

When I run any Gradle task from Eclipse, Gradle is taking another JDK on my system (moreover, only JRE). The only way I can convince Buildship to use my wished JDK is to go to Run Configurations and in Java Home tab specify the JDK again. But this is super inconvenient to do it for every Run configuration separately.

When I execute Gradle from command line, it takes the proper one from JAVA\_HOME. The problem occurs only when using Buildship.

Is there any way, how I can set Java home in Buildship globally?

Thanks  
Martin

---

<div class="post-metadata">

### Author: ![st\_oehme](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/st_oehme/32/5249_2.png) [@st\_oehme](https://discuss.gradle.org/u/st_oehme)
#### Post date: [February 6, 2017, 10:17pm UTC](https://discuss.gradle.org/t/specifying-jre-in-eclipse-using-buildship-does-not-work/21474/2 "2017-02-06T22:17:13Z")

</div>

Instead of relying on JAVA\_HOME (which doesn’t work in the IDE as you have found out), you can use `org.gradle.java.home` in the [gradle.properties](https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties) inside your Gradle user home directory. That will apply to both command line and IDE builds.

---

<div class="post-metadata">

### Author: ![martin-linha](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@martin-linha](https://discuss.gradle.org/u/martin-linha)
#### Post date: [February 7, 2017, 8:38am UTC](https://discuss.gradle.org/t/specifying-jre-in-eclipse-using-buildship-does-not-work/21474/3 "2017-02-07T08:38:21Z")

</div>

This works, it’s quite clumsy though. Now I need to tell all developers to put it there and maintain it every time there is a new JDK update. Moreover, it’s confusing when I pick different JDK on Eclipse but Gradle executes with the one specified in gradle.properties.

The question is, why Gradle is not started with JRE I choose in Eclipse?  
Are there any plans to fix this?

Thanks!  
Martin

---

<div class="post-metadata">

### Author: ![st\_oehme](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/st_oehme/32/5249_2.png) [@st\_oehme](https://discuss.gradle.org/u/st_oehme)
#### Post date: [February 7, 2017, 8:52am UTC](https://discuss.gradle.org/t/specifying-jre-in-eclipse-using-buildship-does-not-work/21474/4 "2017-02-07T08:52:43Z")

</div>

Gradle is started with the JRE/JDK that Eclipse is started with if you don’t specify anything in your gradle.properties.

I don’t yet understand what the difference is between putting the right java home in gradle.properties and putting it in the Eclipse configuration. Both would have to be updated if you change your Java home.

---

<div class="post-metadata">

### Author: ![dellik2004](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dellik2004](https://discuss.gradle.org/u/dellik2004)
#### Post date: [May 6, 2017, 11:53am UTC](https://discuss.gradle.org/t/specifying-jre-in-eclipse-using-buildship-does-not-work/21474/5 "2017-05-06T11:53:18Z")

</div>

You can set your own JAVA\_HOME by following below…

- Go to Gradle Task in Eclipse.
- Right click on which gradle task you need to run and select “Open gradle run configurations”
- Then go to JAVA\_HOME tab.
- Browse to JDK that you want to use.
- Then apply…

Thats it, it should help…

---

<div class="post-metadata">

### Author: ![atbtm](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/atbtm/32/7375_2.png) [@atbtm](https://discuss.gradle.org/u/atbtm)
#### Post date: [December 4, 2018, 3:43pm UTC](https://discuss.gradle.org/t/specifying-jre-in-eclipse-using-buildship-does-not-work/21474/6 "2018-12-04T15:43:47Z")

</div>

works for me. thanks

---

<div class="post-metadata">

### Author: ![hanshnrch](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/hanshnrch/32/7526_2.png) [@hanshnrch](https://discuss.gradle.org/u/hanshnrch)
#### Post date: [March 1, 2019, 10:10am UTC](https://discuss.gradle.org/t/specifying-jre-in-eclipse-using-buildship-does-not-work/21474/7 "2019-03-01T10:10:37Z")

</div>

It’s an old entry, I know. But hits my problem. To answer your question, why gradle.properties is not the right place to put specific java homes into it: gradle.properties is in version control. It will be used by all developers of the project and also in Jenkins/CI builds. The configuration of java is done elsewhere - in Jenkins or in eclipse Installed JREs preferences. Now I have the problem, that gradle starts with Java 11 (the java eclipse starts with), while the JRE of the project is still Java 8. Some of the plugins fails with Java 11. So the whole “Refresh Task For All Projects” in the Gradle Task view fails already, leaving all projects crossed out. No way to configure “Gradle run configuration”. The only chance I have is to start eclipse with java 8.

---

<div class="post-metadata">

### Author: ![staffanf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/staffanf/32/6017_2.png) [@staffanf](https://discuss.gradle.org/u/staffanf)
#### Post date: [March 19, 2019, 7:03am UTC](https://discuss.gradle.org/t/specifying-jre-in-eclipse-using-buildship-does-not-work/21474/8 "2019-03-19T07:03:35Z")

</div>

> [@hanshnrch](#):
>
> gradle.properties is in version control.

Actually there are 2 places for gradle.properties:

- In your project dir, which is typically version controlled
- In your GRADLE\_HOME\_DIR, typically ~/.gradle/gradle.properties. This is not version controlled and the typical place to configure your on environment

Stefan wrote:

> [@st\_oehme](#):
>
> you can use `org.gradle.java.home` in the [gradle.properties](https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties) inside your Gradle user home directory.
