First of all, know the two commands
where java command to see where your java.exe file is
The java -version command to view your own jdk version.
Methods as below:
One: Delete the three files java.exe, javaw.exe and javaws.exe in the C:\Windows\System32 directory.
Two: Delete C:\ProgramData\Oracle\Java\javapath in the environment variable Path.
Three: If the above fails, the environment variable configuration problem.
For example, the jdk is 121 at the beginning, and the environment variable is changed to 171, but the java -version is still 121. The
solution is to add %JAVA_HOME%\jre\lib to the path and it will be fine.