问题
So a while back I installed some .jar files for game mods, which seems to have installed the 1.8 JRE on my computer. Now, I installed JDK 14, however, my computer still thinks that my Java version is 1.8. I have two Java folders on my computer - one in Program Files with the JDK, and one in Program Files (x86) with the old JRE.
I set the JAVA_HOME environment variable to the directory of the JDK but when I type java -version in my Command Prompt it still says 1.8. How do I get my computer to run Java from JDK 14?
*Apologies if this doesn't make much sense, I still don't know much about how computers work.
回答1:
I'm assuming you are using Windows based on Program Files (x86) folder. Let say it is Windows 10.
Go to environment variable, system variables section.
- change 
CLASSvalue to ...\java14\bin - change 
classpathvalue to ...\java14\lib\ *.jar - change 
JAVA_HOMEvalue to ...\java14 - change 
PATHvalue to ...\java14\bin (be sure to move this up to the top) 
Substitute the name of your jdk folder to java14
Now it should perform as expected. javac will be version 14, java will be version 14 too.
来源:https://stackoverflow.com/questions/63910493/how-to-make-your-computer-change-java-path