JAVA_HOME 环境变量和 Java JDK 的乐趣

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3820954/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 05:29:34  来源:igfitidea点击:

JAVA_HOME environment variable and Java JDK fun

javajava-home

提问by Vidar

I wanted to get Java running at 1.6xxx - I changed the JAVA_HOME variable and pointed it to the directory C:\Program Files\Java\jdk1.6.0._16.

我想让 Java 在 1.6xxx 上运行 - 我更改了 JAVA_HOME 变量并将其指向目录 C:\Program Files\Java\jdk1.6.0._16。

I restart the PC - and I think I can check which version of Java my machine is pointing at - but it still points to the older version of Java e.g v1.5.0_16

我重新启动 PC - 我想我可以检查我的机器指向哪个版本的 Java - 但它仍然指向旧版本的 Java,例如 v1.5.0_16

Can you help me rejog my memory on correct setup for Java JDK?

你能帮我重新回忆一下 Java JDK 的正确设置吗?

java home

爪哇之家

采纳答案by Jigar Joshi

You need to reset your path variable to point to 1.6

您需要将路径变量重置为指向 1.6

something like
alt text

就像是
替代文字

Additionally, make sure the variable JAVA_HOMEis also set with the above location.

此外,请确保变量JAVA_HOME也设置为上述位置。

回答by Qwerky

JAVA_HOME is used by other applications, such as Tomcat. Windows just checks the PATH environment variable for locations where it can find the java executable.

JAVA_HOME 被其他应用程序使用,例如 Tomcat。Windows 只检查 PATH 环境变量以查找可以找到 java 可执行文件的位置。

回答by Andreas Dolk

Try this on the cmd shell:

在 cmd shell 上试​​试这个:

> java -version
java version "1.5.0_16"
> set PATH=%JAVA_HOME%\bin;%PATH%
> java -version

回答by KarSho

This Image will explain all steps. enter image description here

此图像将解释所有步骤。 enter image description here

For More Explanation

更多解释