# Gradle and Eclipse's Java version

**URL:** <https://discuss.gradle.org/t/gradle-and-eclipses-java-version/29997>\
**Category:** Help/Discuss\
**Tags:** eclipse\
**Created:** [December 28, 2018, 3:22pm UTC](https://discuss.gradle.org/t/gradle-and-eclipses-java-version/29997 "2018-12-28T15:22:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbee](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/tbee/32/7406_2.png) [@tbee](https://discuss.gradle.org/u/tbee)\
**Post date:** [December 28, 2018, 3:22pm UTC](https://discuss.gradle.org/t/gradle-and-eclipses-java-version/29997/1 "2018-12-28T15:22:58Z")

</div>

JFXtras version 9 has a Gradle build file with a correctly set sourceCompatibility (=9) but refreshing the project in Eclipse keeps (re)setting it to Java 8. What is the correct way to have Eclipse set the correct JDK when switching between branches (and Java versions)?

---

<div class="post-metadata">

**Author:** ![tbee](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/tbee/32/7406_2.png) [@tbee](https://discuss.gradle.org/u/tbee)\
**Post date:** [December 30, 2018, 1:32pm UTC](https://discuss.gradle.org/t/gradle-and-eclipses-java-version/29997/2 "2018-12-30T13:32:10Z")

</div>

It would also help if the Gradle eclipse plugin would configure the workspace default for both runtime and compiler settings, instead of project specific settings, then I could switch it in one go for all subprojects.

---

<div class="post-metadata">

**Author:** ![tbee](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/tbee/32/7406_2.png) [@tbee](https://discuss.gradle.org/u/tbee)\
**Post date:** [December 30, 2018, 1:32pm UTC](https://discuss.gradle.org/t/gradle-and-eclipses-java-version/29997/3 "2018-12-30T13:32:50Z")

</div>

Maven keeps luring me to switch back.

---

<div class="post-metadata">

**Author:** ![tbee](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/tbee/32/7406_2.png) [@tbee](https://discuss.gradle.org/u/tbee)\
**Post date:** [December 30, 2018, 8:13pm UTC](https://discuss.gradle.org/t/gradle-and-eclipses-java-version/29997/4 "2018-12-30T20:13:10Z")

</div>

I’ve added this to the build, which removes JavaSE-1.8 and adds JavaSE-9, and marks the test source folders as containing tests. This seems so trivial that the eclipse plugin should really handle this.

```
	// Force Java 9 in Eclipse config
	eclipse {
	   classpath {
	        containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-9/'
			file {
	    		whenMerged { classpath ->
	    			classpath.entries.removeAll { entry -> entry.kind == 'con' && !entry.path.contains('JavaSE-9')}
					classpath.entries.findAll{ it.kind == 'src' && it.path.contains('/test/') }.each { 
						it.entryAttributes['test'] = 'true'
					}
				}
	   		}
	   }
	   jdt {
			sourceCompatibility = org.gradle.api.JavaVersion.VERSION_1_9
			targetCompatibility = org.gradle.api.JavaVersion.VERSION_1_9
	   }
	}
```

---

<div class="post-metadata">

**Author:** ![zosrothko](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/zosrothko/32/5438_2.png) [@zosrothko](https://discuss.gradle.org/u/zosrothko)\
**Post date:** [January 21, 2019, 2:17pm UTC](https://discuss.gradle.org/t/gradle-and-eclipses-java-version/29997/5 "2019-01-21T14:17:24Z")

</div>

JDK 1.9 is no more available for downloading. I would suggest to switch to Java-1.10 or Java-1.11

Downloding [JDK-1.9](https://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html)

---

<div class="post-metadata">

**Author:** ![Jafario](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jafario/32/7461_2.png) [@Jafario](https://discuss.gradle.org/u/Jafario)\
**Post date:** [February 2, 2019, 4:32am UTC](https://discuss.gradle.org/t/gradle-and-eclipses-java-version/29997/6 "2019-02-02T04:32:15Z")

</div>

I don’t know if this is the right place to go for this problem, but I’m new to all of this and I’m really confused. I was trying to install Gradle onto my pc (Windows 10), but every time I try and check the status of the installation using the “gradle -v” command in the powershell it comes up with this reply:

gradle : The term ‘gradle’ is not recognized as the name of a cmdlet, function, script file, or operable program.  
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.  
At line:1 char:1

- gradle -v
- 

```gradle
  + CategoryInfo : ObjectNotFound: (gradle:String) [], CommandNotFoundException
  + FullyQualifiedErrorId : CommandNotFoundException

```

> Blockquote

I’m sure I put in the correct directory for the environment variables. But I am really new to this stuff and I’m not sure on anything. If anyone can, please help me install it correctly.

---

<div class="post-metadata">

**Author:** ![zosrothko](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/zosrothko/32/5438_2.png) [@zosrothko](https://discuss.gradle.org/u/zosrothko)\
**Post date:** [February 9, 2019, 3:04pm UTC](https://discuss.gradle.org/t/gradle-and-eclipses-java-version/29997/7 "2019-02-09T15:04:45Z")

</div>

Under a DOS windows, the native command for invoking Gradle is: gradlew -v
