如何更改Javac版本?

huangapple go评论75阅读模式
英文:

How to change the Javac version?

问题

在 Windows 10 上,我成功地将我的 Java 版本更改为 JDK 1.8:

C:\Users\Boommeister69>java -version
java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)

但是 javac 没有改变:

C:\Users\Boommeister69>javac -version
javac 11.0.7

当我执行 echo %PATH% 时,结果如下:

C:\Users\Boommeister69>echo %PATH%
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;

C:\Program Files\AdoptOpenJDK\jdk-11.0.7.10-hotspot\bin;

C:\Python38\Scripts\;C:\Python38\;C:\Program Files (x86)\Intel\iCLS Client\;
C:\Program Files\Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;
C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;
C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;
C:\Program Files\Amazon\AWSCLIV2\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\Git\cmd;C:\Program Files\MariaDB 10.5\bin;

C:\Program Files\Java\jdk1.8.0_261\bin;

C:\Program Files\PuTTY\;C:\Program Files\CMake\bin;C:\Program Files\Amazon\AWSSAMCLI\bin\;

C:\Program Files\Java\jdk1.8.0_261\bin;

C:\Users\Boommeister69\AppData\Local\Microsoft\WindowsApps;C:\Users\Boommeister69\AppData\Roaming\npm;
C:\Users\Boommeister69\AppData\Local\Temp\apache-maven-3.6.3-bin\apache-maven-3.6.3\bin;
C:\Program Files\heroku\bin;
C:\workspace\play-samples-play-java-hello-world-tutorial;C:\Program Files\Maven\apache-maven-3.6.3\bin;
C:\Users\Boommeister69\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\Docker Toolbox;

因此,我在这里看到了3个带有 Java JDK 的路径,第一个 JDK 路径仍然设置为 Java 11。我认为这是问题所在,但我不知道如何更改这个?为什么会显示这么多路径,echo %PATH% 不应该只返回系统环境路径变量吗?

以下是我的系统环境路径变量:

如何更改Javac版本?

以及我的 JAVA_HOME 变量:

如何更改Javac版本?

我还更改了 IntelliJ 中的 SDK,尽管我认为这与 javac 无关:

如何更改Javac版本?

如何更改Javac版本?

如何更改Javac版本?

英文:

On Windows 10, I successfully changed my java version to JDK 1.8:

C:\Users\Boommeister69>java -version
java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)

but javac doesn't change:

C:\Users\Boommeister69>javac -version
javac 11.0.7

when I echo %PATH% this is the result:

C:\Users\Boommeister69>echo %PATH%
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;

C:\Program Files\AdoptOpenJDK\jdk-11.0.7.10-hotspot\bin;

C:\Python38\Scripts\;C:\Python38\;C:\Program Files (x86)\Intel\iCLS Client\;
C:\Program Files\Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;
C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;
C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;
C:\Program Files\Amazon\AWSCLIV2\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\Git\cmd;C:\Program Files\MariaDB 10.5\bin;

C:\Program Files\Java\jdk1.8.0_261\bin;

C:\Program Files\PuTTY\;C:\Program Files\CMake\bin;C:\Program Files\Amazon\AWSSAMCLI\bin\;

C:\Program Files\Java\jdk1.8.0_261\bin;

C:\Users\Boommeister69\AppData\Local\Microsoft\WindowsApps;C:\Users\Boommeister69\AppData\Roaming\npm;
C:\Users\Boommeister69\AppData\Local\Temp\apache-maven-3.6.3-bin\apache-maven-3.6.3\bin;
C:\Program Files\heroku\bin;
C:\workspace\play-samples-play-java-hello-world-tutorial;C:\Program Files\Maven\apache-maven-3.6.3\bin;
C:\Users\Boommeister69\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\Docker Toolbox;

So I have 3 paths showing up there with Java JDKs, the first JDK path is still set to Java 11. I think this is the problem, but I don't know how to change this? And why are there so many paths showing up, shouldn't echo %PATH% only return the system environment path variables?

These are my system environment path variables:

如何更改Javac版本?

and my JAVA_HOME variable:

如何更改Javac版本?

I also changed the SDK in my IntelliJ, altough I don't think this has something to do with javac:

如何更改Javac版本?

如何更改Javac版本?

如何更改Javac版本?

答案1

得分: 0

你尝试过重新启动Windows吗?

在“环境变量”下有两个部分:“用户变量”和“系统变量”。 JAVA HOME 可能在其中的两者之一。

英文:

Have you tried restarting Windows?

Under "Environment Variables" there are 2 section; "User variables for ..." and "System variables". JAVA HOME might be in both of them.

答案2

得分: 0

好的,我找到一个不太干净的解决方法:
我只是移除了整个JDK 11文件夹 C:\Program Files\AdoptOpenJDK\jdk-11.0.7.10-hotspot

英文:

Ok I found a dirty solution:
I just removed the whole folder of my JDK 11 C:\Program Files\AdoptOpenJDK\jdk-11.0.7.10-hotspot

huangapple
  • 本文由 发表于 2020年9月2日 16:28:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/63701617.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定