I'm tryig to build my spring boot project with this command.
./gradlew build
But it continuously throws this error.
'Execution failed for task ':compileJava'. invalid source release: 11'.
My project is using java version 11, and IntelliJ java version is set to 11 as well.
This is the java version settings on my IntelliJ that I've done so far.
1. Settings - Build, Execution, Deployment - Build Tools - Gradle
-> set to 11.
[![enter image description here][1]][1]
2. Settings - Build, Execution, Deployment - Compiler - Java Compiler - Project bytecode version
-> set to 11.
[![enter image description here][1]][1]
java -version command on IntelliJ Terminal
-> set to 11.0.12
Project Structure - Project Settings - Project - Project SDK: -> set to 11.
Project Structure - Project Settings - Modules - Module SDK: -> set to 11.
Project Structure - Platform Settings - SDKs - JDK home path:
-> set to 11.
build.gradle - sourceCompatibility, targetCompatibility
-> set to 11.
After all of this when I run
./gradlew build
I think I've done everything possible. Is there any other settings that I can try ??
CodePudding user response:
There are 2 solutions. The problem is likely happening because Gradle Wrapper tried to find JDK 11 in Java_home and failed to find it there. I don't think it's because you are using some old deprecated dependencies that don't support jdk11.
Solution1
Explicitly mention the JDK you want to use on terminal. For example, instead of
./gradlew build
Use
./gradlew build -Dorg.gradle.java.home=yourjdk11homepath
Your path might be something like:
C:\\Program Files\\OpenJDK\\jdk-11.0.3
Solution 2
If you don't want to apply solution1 whenever you build project using gradle wrapper, you set the option in gradle.properties file.
On the same directory level as build.gradle and gradlew files, make
gradle.properties
file and write following:
org.gradle.java.home=yourjdk11homepath
Again, your path might be something like:
C:\\Program Files\\OpenJDK\\jdk-11.0.3
CodePudding user response:
Set project jdk to 1.8 instants 11