IntelliJ says 'Project JDK is Misconfigured', but it isn't, how can this be fixed?
Asked Answered
H

2

7

I'm running IntelliJ Ultimate 2022.2.2. For quite some time (and versions) it has been complaining that the Project JDK is misconfigured and giving red lines under basically everything. This wasn't much of a problem aside from being very annoying, because the build configurations and Maven tasks still worked, but now it appears that breakpoints don't work anymore, which is a bit of an issue.

The exact issue is that in the POM, the Java version is set to 11. The JDK is also set to 11, as is the language level. IntelliJ, however, will only remove the warning (and red lines) if the JDK is set to 8 instead. Of course, doing that causes compilation and Maven tasks to fail, because the POM specifies that Java 11 must be used.

As stated above, I tried following IntelliJ's suggestion of changing the JDK to Java 8, which removed the editor warnings and errors, but caused compilation and Maven jobs to fail. Leaving it at 11 compiles and runs just fine, but the editor is filled with errors and warnings and breakpoints don't function.

I've also tried a clean checkout with invalidated caches, but that resulted in the exact same situation.

Why, then, does IntelliJ claim the project JDK is misconfigured, and how can I convince it that it really isn't?

Hyp answered 10/11, 2022 at 9:21 Comment(3)
Maybe it's the non-Java-8 JDK inside of IntelliJ that's configured wrongly somehow? Try checking Project Structure -> SDKs and see which JDKs you have configured.Amused
Could you click on Reload All Maven Projects in the Maven tool window and provide screenshots from File | Project Structure | Project, File | Project Structure | SDKs | select JDK configured for the project, File | Project Structure | Modules | select your module | Depenedencies?Kirtle
See if jetbrains.com/help/idea/maven-support.html#change_jdk helpsKirtle
S
13

I ran into the same problem recently. I also couldn't understand why I got this error.

Although

Project Structure -> Project Settings -> Project -> SDK was set correctly

Project Structure -> Platform Settings -> SDKs -> JDK home path was set correctly (see screen)

But later I noticed that the red square was empty. Not sure how it could happen. I just pressed [-] to remove the SDK and added it again. The compile errors disappeared.

enter image description here

Stoichiometric answered 28/6, 2024 at 15:16 Comment(1)
hah. spent a couple of hours trying to fix this. same problemShostakovich
D
2

Got the same issue after fresh instalation of both JDK and IntelliJ. The following fixes worked for me.


Temporary fix:

If you have more than one JDK - change it to any other you have and back, it should help.


Permanent fix:

  • Go to Project Structure (CTRL + ALT + SHIFT + S)
  • Go to SDKs under Platform Settings
  • You would probably have Classpath list empty
  • Remove (-) SDK you have problem with and add (+) it again
  • Now Classpath list should be loaded properly

I would recommend going with the second fix since its applied globally.

Dahlia answered 30/7, 2024 at 18:20 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.