# How to set sourceCompatibility

**URL:** <https://discuss.gradle.org/t/how-to-set-sourcecompatibility/42374>\
**Category:** Help/Discuss\
**Created:** [March 5, 2022, 10:47pm UTC](https://discuss.gradle.org/t/how-to-set-sourcecompatibility/42374 "2022-03-05T22:47:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eriol](https://avatars.discourse-cdn.com/v4/letter/e/0ea827/32.png) [@Eriol](https://discuss.gradle.org/u/Eriol)\
**Post date:** [March 5, 2022, 10:47pm UTC](https://discuss.gradle.org/t/how-to-set-sourcecompatibility/42374/1 "2022-03-05T22:47:53Z")

</div>

I’m completely new to Gradle. I tried to search the docs and the forum but unfortunately I didn’t find a solution. So I’ll ask here.  
I’m trying to compile a project that I cloned and get this error:

> Cause: org/openjfx/gradle/JavaFXPlugin has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 54.0

My Java home and org.gradle.java.home is both set to Java 17. I believe the problem is with sourceCompatibility setting but I can’t figure out how to set this property.  
Using `sourceCompatibility = 17` in build.gradle gives me this error:

> Caused by: groovy.lang.MissingPropertyException: Could not set unknown property ‘sourceCompatibility’ for root project

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [March 8, 2022, 11:06pm UTC](https://discuss.gradle.org/t/how-to-set-sourcecompatibility/42374/2 "2022-03-08T23:06:35Z")

</div>

class file version 55 is Java 11, 54 is Java 10.  
So the error is saying that you use Java 10 to execute a Gradle build where a version of the JavaFXPlugin is applied that needs at least Java 11 to run.  
Setting any source compatibility or similar will not help you at all.  
If you run `./gradlew --help` it will display which Java version is used and it is most likely a Java 10 version.  
Maybe you have `JAVA_HOME` set to a Java 10 path.

---

<div class="post-metadata">

**Author:** ![Eriol](https://avatars.discourse-cdn.com/v4/letter/e/0ea827/32.png) [@Eriol](https://discuss.gradle.org/u/Eriol)\
**Post date:** [March 9, 2022, 9:43pm UTC](https://discuss.gradle.org/t/how-to-set-sourcecompatibility/42374/3 "2022-03-09T21:43:20Z")

</div>

Thanks for replying.  
Command `./gradlew --version` told me this:

```gradle
Gradle 7.4
------------------------------------------------------------
Build time: 2022-02-08 09:58:38 UTC
Revision: f0d9291c04b90b59445041eaa75b2ee744162586
Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 17.0.1 (Eclipse Adoptium 17.0.1+12)
OS: Windows 10 10.0 amd64

```

I also double-checked that `JAVA_HOME` is set to my Java 17 JDK path.

I’m using IntelliJ IDEA btw if that makes any difference.

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [March 9, 2022, 10:19pm UTC](https://discuss.gradle.org/t/how-to-set-sourcecompatibility/42374/4 "2022-03-09T22:19:22Z")

</div>

Of course it does.  
If you check with `./gradlew --version` then it is only meaningful for running your build also from commandline.  
When you run Gradle from IDE, you have to check what you configured in the IDE to run Gradle with in the settings dialog, or by running `gradle --version` from the IDE.

---

<div class="post-metadata">

**Author:** ![Eriol](https://avatars.discourse-cdn.com/v4/letter/e/0ea827/32.png) [@Eriol](https://discuss.gradle.org/u/Eriol)\
**Post date:** [March 9, 2022, 10:24pm UTC](https://discuss.gradle.org/t/how-to-set-sourcecompatibility/42374/5 "2022-03-09T22:24:21Z")

</div>

Ah, should have thought of that. But I didn’t expect that setting there as Maven get the JDK from the project pom.  
Now it works. Thanks!
