79547497

Date: 2025-04-01 00:46:47
Score: 0.5
Natty:
Report link

One can run into this error despite using Java version below JDK 21 for the project if the Project settings in IntelliJ was using JDK 21 to compile.

Here's an example:

The pom.xml has java level set to 17

enter image description here

The Module Settings show the level as 17

enter image description here

But the Project setting picked up the JDK 21 installed on my machine

enter image description here

Fix

Change the SDK to use JDK 17 and it should work fine

enter image description here

Reasons:
  • Probably link only (1):
  • No code block (0.5):
  • High reputation (-1):
Posted by: Aditya Vikas Devarapalli