I Faced the same issue while upgrading to OpenJDK17 from JDK8 and got this error while trying Javaexecuting -versionJava -version in cmd.
Fix: As pointed out by others in this threadgoto path C:\Program Files\Java\jdk-17\bin copy files java.exe and javaw.exe, goto path C:\ProgramData\Oracle\Java\javapath and delete the existing shortcuts.( I had java 8 before this and shortcuts were placed to java.exe, javaw.exe & javaws.exe. In case of Java 17 javaws.exe is no longer available in the java\bin so this is not required) and shortcuts didn't work in my case so I placed thepaste these two files itself directly in the path(C:\ProgramData\Oracle\Java\javapath) from binthere.