简体   繁体   English

Windows 7提示中的Java神秘路径

[英]Java mystery path in Windows 7 prompt

I recently noticed that my PATH setting in Windows had incorrect pointers to older versions of Java. 最近,我注意到Windows中的PATH设置指向旧版本Java的指针不正确。 What is odd is that the java -version command still works at the command prompt and it gives the version of Java that does correspond to the latest JRE I have installed. 奇怪的是java -version命令仍然在命令提示符下运行,并且给出的Java版本确实与我安装的最新JRE相对应。 This is also the version represented in Control Panel and it is the VM version referenced by Eclipse. 这也是“控制面板”中表示的版本,也是Eclipse引用的VM版本。 What I'm confused about is how does the command prompt know where to find the java executables if the path is set incorrectly? 我感到困惑的是,如果路径设置不正确,命令提示符如何知道在哪里可以找到Java可执行文件?

There is no mystery. 没有神秘感。 There are going to be at least two versions of Java installed on your computer: The one you installed manually, and the one Windows uses (most likely inside the \\system32 folder). 您的计算机上至少将安装两个Java版本:一个是您手动安装的,另一个是Windows使用的(最有可能在\\ system32文件夹中)。

when you type the java command at the command prompt, the operating system (windows) resolves this command by: 1) executing the command located on the current directory, 2) finding the command in one of the paths declared in the PATH. 当您在命令提示符下键入java命令时,操作系统(Windows)通过以下方式解析该命令:1)执行位于当前目录中的命令,2)在PATH中声明的路径之一中查找命令。

I have multiple Java versions installed on my computer. 我的计算机上安装了多个Java版本。 The one I want to use to develop software is the one I made sure is declared first on my PATH variable. 我要用来开发软件的是我确保首先在PATH变量上声明的软件。

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

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