Home > Mobile >  IntelliJ Gradle build failure: Incompatible because component compatible with Java 17 and the consum
IntelliJ Gradle build failure: Incompatible because component compatible with Java 17 and the consum

Time:01-08

In IntelliJ, when I do a clean build on a new project downloaded from start.spring.io, it gives an error.

enter image description here

  1. You also need the following configuration. File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle -> Gradle JVM and specify a jdk of 17 or later.

enter image description here

Keep in mind that the above configurations apply to the embedded version of gradle which InteliJ uses as an embedded tool. Not the one configured to run from Terminal

In order to use the embedded tool version for gradle terminal which will already be set up with Jdk 17 according to the above configurations, you need to run commands as shown bellow:

enter image description here

This should be enough to execute your project.

Otherwise If you insist on using the terminal to execute gradle commands, then you need to make all the necessary adaptations in environmental variables. To do so head into File -> Settings -> Tools -> Terminal -> Enviroment Variables . For environmental changes to take effect you have to restart InteliJ window. After restart you can confirm with gradle -version command if the correct JVM and gradle version is set up or not. Also you can use the java -version to see in what JDK the terminal points to. Spring Boot Initializer delivers also a portable gradle file which is compatible to run the project. So if you have under environmental properties another gradle installed in your system you can detect with above commands and remove so that you can use only the local one which is shipped.

  • Related