error running maven tool in intellij - "SDK 17 is not compatible with the source version 17"
Answered
I have a module that uses maven and java 17. It compiles fine from the command line with mvn. When I try to use the intellij Maven tool (on right sidebar) to run the install lifecycle, I get this error:
invalid target release: 17
Module my-module SDK 17 is not compatible with the source version 17.
Upgrade Module SDK in project settings to 17 or higher. Open project settings.
The module SDK is set to 17 (17.0.1) in the project settings. Not sure what is wrong.
Thanks
Please sign in to leave a comment.
What is the language level set for project and SDK set for the module?
Please share the screenshot of your project and module settings.
Hello Konstantin,
The project SDK is 1.8 and the project language level is 8. The module SDK is 17 and the module language level is 17 (preview).
Where does the Maven run? 8, or 17? Check the "Preferences | Build, Execution, Deployment | Build Tools | Maven | Runner" by default, project's JDK is chosen rather than module's one.
Dear, Konstantin Annikov
I got the same issue. I don't understand your solution clearly. Can you have a better instruction?
Nguyen Duc Y
Go to File | Settings | Build, Execution, Deployment | Build Tools | Maven | Runner dialog. What is the version of the JRE selected there?
I had same issue in multimodule maven project with libs for spring-boot projects. Used spring-boot-dependencies 2.7.3, jdk-17.0.5 libs. I upgraded Idea to 2022.2.3 UE, sets version 17 in all above locations. Maven builds successfully several modules but fails in one with absolutely same settings with error: module [bla-bla-bla] SDK 17 is not compatible with the source version 17. Removing of one dependency org.apache.kafka:kafka-clients:2.5.1 helped me, error disappears
I had the same issue. I created Spring Boot 3.0 application with Java 17, opened it in Intellij IDEA and I couldn't build it because of almost the same error as OP mentioned. In project settings version 17 was chosen. And I don't have Kafka in pom.xml, like person above.
It appears that even though I could choose version 17, the downloaded SDK was in version 16. I downloaded SDK 19, selected version 17 afterwards and project built successfully.
Please help what to do in this case
Hello,
What source/target level is configured in your pom.xml file?
Hi Yaroslav.
I have enconterd same error. My project Runner is below
module setting:
Run/debug configuration:
and my pom.xml
Whan can I do to cope this error?
Hello,
I changed it like bellow and error gone away.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/4424982618258/comments/9232966890002
Same 225101403 mentioned on the screens
Same initial settings with 225101403.
But solved the problem by setting Project Structure -> Modules -> Language level to 8 instead of removing those two maven.compiler lines.
I know that this is a bit older topic, but here it is if someone is still struggling. If nothing else works, update dependencies.
I have found one of the causes if you're using spring boot or any framework with maven Transitive dependencies has Jre17 runtime in my case mssql running in jre17. please check Effective Pom.xml I went by right clicking in pom.xml →maven→ Show Effective POM and Searched for Jre17 tag. So, check the dependencies and Transitive dependency any of them required higher version of java.
Note:- Should not use Spring boot 3 or higher
Hope Its Help some one
I have attached Effective POM screenshot
You have to check the bytecode target, as in my image
Thank you! Fixed my issue - but I feel IntelliJ could flags this in the error better - e.g. Check Maven → Runner matches as a hint as this would have saved me some time for sure fighting this. It's not obvious at all
Pasquale Grimaldi thanks your solution worked for me.