0

I am using Intellij 2022.2 Ultimate version. I have recently started to work on project which involves java17. This is a spring boot application. I am trying to do a maven package from the IDE (From the maven tab in Intellij) I am getting the below error.

invalid target release: 17
Upgrade Module sdk in project settings to 17 or higher. 

When I try to add jdk 17 to my sdk, I get an error saying.

"Cannot find jdk classes in the folder"

But the same thing run via command maven. Below is the output of mvn -v

Apache Maven 3.8.6
Maven Home: c:\Progam Files\apache-maven-3.8.7-bin\apache-maven-3.8.6
Java version: 17.0.5, Vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk17

Intellij does seem to recognize the jdk libraries. i searched some forums and found that there should be a library called tools.jar which will help Intellij identify the jdk as jdk. but unfortuntely jdk17 does not have that. or altest my installation does not and this is an official laptop. So installing anything is pretty much not in my hands.

Any help on how to make this work in Intellij would be appreciated.

Seeker
  • 163
  • 1
  • 12
  • 1
    I think the `tools.jar` is a bit of a red herring. IIRC it's not been present for a while now (since Java 9) and IDEA 2022.2 should support Java 17. Did you provide the correct directory when trying to add the JDK to IDEA? I think it wants the root directory (i.e. that *contains* `bin/` and others, which should be just `C:\Program Files\Java\jdk17` in your case). – Joachim Sauer Mar 29 '23 at 11:52
  • Have you added jdk like this? https://stackoverflow.com/a/49105753/7034621 – orhtej2 Mar 29 '23 at 11:53
  • yea. i am adding it the way it is there in the link. I am providing the path upto the folder which has bin. I also tried to invalidate the caches and restart. Deleted the .idea folder and did a import project again. still it is not working. – Seeker Mar 29 '23 at 11:59

1 Answers1

0

I restated my Intellij and i noticed that it was downloading prebuild shared indexes with pre-built jdk. I stopped that process and configured the settings to "Always ask before downloading". and now i am able to add jdk17.

Seeker
  • 163
  • 1
  • 12