I use java 21 gradle 8.5 intellij 2023.2.2
In a spring boot 3.2 project in the build.gradle i have
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.0'
id 'io.spring.dependency-management' version '1.1.4'
}
group = 'com.acme.intranet-backend'
version '0.0.34-SNAPSHOT'
java {
sourceCompatibility = '21'
}
when i build project, i
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':intranet:compileJava'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:148) at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:146) at Caused by: java.lang.IllegalArgumentException: error: invalid source release: 21
By default, IDEA uses Gradle wrapper which in turn uses its own configuration of Java runtime.
If you go into
Settings -> Build, Execution, Deployment -> Gradle
you can change Gradle default JVM into Java 21 ("Gradle JVM" property).
If you do not have JDK 21 installed, select "Download SDK" and pick one of Java 21 versions (personally I prefer Eclipse Temurin SDK).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With