I downloaded newer version of Eclipse and this error was showing up when using Maven, although I put JDK 17 where I could. For me worked something similar to above answer.
I had independent Maven which was using JAVA_HOME (on 17) outside of Eclipse, correctly. I added it to the list of Mavens and choose it, and it used Java 17 when used from Eclipse. After one use, even embedded Maven started to use Java 17. Embedded Maven was probably taking Java 15 from the previous Eclipse or something.
Mavens are in Eclipse on: Window - Preferences - Maven - Installations, like for the whole, not for one project.