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?
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.

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