I don't have enough reputation to comment yet, so posting this as an answer in hopes it helps the next person.
I spent around 3 days researching and trying to solve this issue. I found most of the StackOverflow answers as well as guides from other forums. All of those kept saying: Set your JAVA_HOME to some Java21 installation and check using 'mvn -v' to make sure you see a 21.x.x somewhere. This seems so have solved it for everyone else, but not for me.
My JAVA_HOME variable was pointing at Java 21, however for some reason it was installed only as a JRE and not as a JDK. Thus, there was no compiler present.
Make sure your JAVA_HOME variable is not only pointed to some Java 21 installation, but that that installation is a Java JDK, not just a Java JRE!