简体   繁体   English

Windows 10 java -版本不同于 JAVA_HOME

[英]Windows 10 java -version differs from JAVA_HOME

I'm struggling with Java installation on my Windows 10 machine.我正在努力在我的 Windows 10 机器上安装 Java。 If I look at my JAVA_HOME the path is set for Java 13, but when I type in java -version I get a Java 8 as result.如果我查看我的 JAVA_HOME,路径设置为 Java 13,但是当我输入 java -version 时,我得到 ZD52387880E1EA22817A72D3759213889 的结果。 What am I doing wrong?我究竟做错了什么?

在此处输入图像描述

EDIT: I added the JAVA_HOME to my user variables, to my user PATH and it is already inside the regular PATH, still no change, even after rebooting the machine.编辑:我将 JAVA_HOME 添加到我的用户变量中,添加到我的用户 PATH 中,并且它已经在常规 PATH 中,即使重新启动机器后仍然没有变化。

在此处输入图像描述

Is it possible that the first and third entry of my system PATH is part of the problem?我的系统 PATH 的第一个和第三个条目是否可能是问题的一部分? These folders point to a JAVA 8 java.exe.这些文件夹指向 JAVA 8 java.exe。

Plase check the PATH variable, both user and system, you'll find a reference to the java 1.8.0_221 installation.请检查用户和系统的 PATH 变量,您将找到对 java 1.8.0_221 安装的引用。

You also could add as the fisrt PATH entry %JAVA_HOME%/bin in order to use the JAVA_HOME refeered JDK您还可以添加作为第一个 PATH 条目 %JAVA_HOME%/bin 以使用 JAVA_HOME 引用的 JDK

You did not set your path for the latest Java version.您没有为最新的 Java 版本设置路径。 Copy the value that you have in your JAVA_HOME, and paste it in your PATH (top of your window).复制您在 JAVA_HOME 中的值,并将其粘贴到 PATH(窗口顶部)中。

Java looks at what is in the PATH Environment Variable, so inside of that variable, you need to paste in the same path that you put into the JAVA_HOME variable. Java 查看 PATH 环境变量中的内容,因此在该变量内部,您需要粘贴到与 JAVA_HOME 变量相同的路径中。 That way the java will be updated to whatever jdk version you are using in the PATH variable.这样,java 将更新为您在 PATH 变量中使用的任何 jdk 版本。 If you want, you can also erase the older jdk from the PATH, so that there are no ambiguities in the version of java that you are using.如果需要,您还可以从 PATH 中删除较旧的 jdk,以便您使用的 java 版本没有歧义。

I also had the same issue.我也有同样的问题。 But I reoder the path.但我重新编码了路径。 Just set the first entry(C:\Program Files (x86)\Common Files\Oracle\Java\javapath) in the provided image before the "%JAVA_HOME&\bin" Entry.只需在“%JAVA_HOME&\bin”条目之前在提供的图像中设置第一个条目(C:\Program Files (x86)\Common Files\Oracle\Java\javapath)。 Aftet that it worked in my case. Aftet 它在我的情况下有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM