“系统找不到文件 C:\ProgramData\Oracle\Java\javapath\java.exe”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26864662/
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
"The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe"
提问by JavaBeginner
I am on JDK 8u25 on Windows 8, and I am experiencing a problem with my Java installation. I can run javac
perfectly fine, but running java
produces this error message:
我在 Windows 8 上使用 JDK 8u25,我的 Java 安装遇到问题。我可以javac
完美运行,但运行java
会产生以下错误消息:
The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe
How do I fix this?
我该如何解决?
I think the problem has to do with my environment variables.
我认为问题与我的环境变量有关。
The important variables, as I have set them, are:
正如我所设置的,重要的变量是:
JAVA_HOME
–C:\Program Files\Java\jdk1.8.0_25
CLASSPATH
–.;%JAVA_HOME%\lib
PATH
–<other paths omitted>;%JAVA_HOME%\bin
JAVA_HOME
——C:\Program Files\Java\jdk1.8.0_25
CLASSPATH
——.;%JAVA_HOME%\lib
PATH
——<other paths omitted>;%JAVA_HOME%\bin
And their expansions, as viewed with set
in cmd, are:
set
在 cmd 中查看它们的扩展是:
JAVA_HOME
–C:\Program Files\Java\jdk1.8.0_25
CLASSPATH
–.;C:\Program Files\Java\jdk1.8.0_25\lib;%CLASSPATH%;
PATH
–C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Java\jdk1.6.0_45\bin;<other paths omitted>;C:\Program Files\Java\jdk1.8.0_25\bin
JAVA_HOME
——C:\Program Files\Java\jdk1.8.0_25
CLASSPATH
——.;C:\Program Files\Java\jdk1.8.0_25\lib;%CLASSPATH%;
PATH
——C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Java\jdk1.6.0_45\bin;<other paths omitted>;C:\Program Files\Java\jdk1.8.0_25\bin
The full output of set
can be viewed here.
set
可以在此处查看的完整输出。
回答by VdeX
Updating the PATH Environment Variable
更新 PATH 环境变量
If you do not set the PATH variable, you need to specify the full path to the executable file every time you run it, such as:
如果不设置PATH变量,则每次运行时都需要指定可执行文件的完整路径,如:
C:\> "C:\Program Files\Java\jdk1.8.0\bin\javac" MyClass.java
It is useful to set the PATH variable permanently so it will persist after rebooting.
To set the PATH variable permanently, add the full path of the jdk1.8.0\bin directory to the PATH variable. Typically, this full path looks something like
C:\Program Files\Java\jdk1.8.0\bin
.
Set the PATH variable as follows on Microsoft Windows:
永久设置 PATH 变量很有用,因此它会在重新启动后保持不变。
要永久设置 PATH 变量,请将 jdk1.8.0\bin 目录的完整路径添加到 PATH 变量中。通常,此完整路径类似于
C:\Program Files\Java\jdk1.8.0\bin
.
在 Microsoft Windows 上按如下方式设置 PATH 变量:
- Click Start, then Control Panel, then System.
- Click Advanced, then Environment Variables.
Add the location of the bin folder of the JDK installation to the PATH variable in System Variables.
The following is a typical value for the PATH variable:C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Java\jdk1.8.0\bin
Note:The PATH environment variable is a series of directories separated by semicolons (;) and is not case-sensitive. Microsoft Windows looks for programs in the PATH directories in order, from left to right.
You should only have one bin directory for a JDK in the path at a time. Those following the first instance are ignored.
If you are not sure where to add the JDK path, append it.
- 单击开始,然后单击控制面板,然后单击系统。
- 单击高级,然后单击环境变量。
在系统变量中的PATH变量中添加JDK安装的bin文件夹的位置。
以下是 PATH 变量的典型值:C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Java\jdk1.8.0\bin
注意:PATH 环境变量是一系列由分号 (;) 分隔的目录,不区分大小写。Microsoft Windows 按从左到右的顺序在 PATH 目录中查找程序。
您一次应该在路径中只有一个 JDK 的 bin 目录。那些跟随第一个实例的将被忽略。
如果您不确定在哪里添加 JDK 路径,请附加它。
The new path takes effect in each new command window you open after setting the PATH variable.
设置 PATH 变量后,新路径在您打开的每个新命令窗口中生效。
回答by Johny
There are 2 versions of jdk in your PATH VARIABLE
jdk1.6.0_45
and jdk1.8.0_25
. Try removing the first one ie. jdk1.6.0_45
from the PATH
在您的PATH VARIABLE
jdk1.6.0_45
和jdk1.8.0_25
. 尝试删除第一个即。 jdk1.6.0_45
来自PATH
回答by Johny
I've got a similar problem I'm currently working on solving. I can't say this will solve your error since there may be issues with other software (which is my case with Eclipse Luna).
我有一个类似的问题,我目前正在解决。我不能说这会解决您的错误,因为其他软件可能存在问题(我的 Eclipse Luna 就是这种情况)。
Java is using the path given in your PATH variable, which is,
Java 正在使用 PATH 变量中给出的路径,即,
C:\ProgramData\Oracle\Java\javapath
Go to this folder (ProgramData is hidden, so unhide it if necessary) and right click on the java.exe symlink. You'll see in the Target field where it's looking for java.exe. It may be pointing to the java.exe file from your previous jdk1.6.0_45 install. Either paste in new shortcuts here or change the PATH setting as others have mentioned.
转到此文件夹(ProgramData 已隐藏,因此如有必要,请取消隐藏它)并右键单击 java.exe 符号链接。您将在目标字段中看到它正在寻找 java.exe。它可能指向您之前安装的 jdk1.6.0_45 中的 java.exe 文件。要么在此处粘贴新的快捷方式,要么像其他人提到的那样更改 PATH 设置。
I've found that the Java installer doesn't change the javapath or update the system path, at least when going from 1.8 to 1.7. In my case changing the shortcuts only led to a problem with Eclipse on startup.
我发现 Java 安装程序不会更改 javapath 或更新系统路径,至少在从 1.8 到 1.7 时是这样。就我而言,更改快捷方式只会导致 Eclipse 在启动时出现问题。
EDIT:----- After playing with javapath folder shortcuts it turns out you need symlinks, at least for Eclipse. See, Windows how to create directory symlink.
编辑:----- 在使用 javapath 文件夹快捷方式后,结果证明您需要符号链接,至少对于 Eclipse。看,Windows 如何创建目录符号链接。
You don't need the /d switch for a file symlink,
您不需要文件符号链接的 /d 开关,
mklink java.exe "C:\Program Files\Java\jdk1.8.0_20\bin\java.exe"
mklink javaw.exe "C:\Program Files\Java\jdk1.8.0_20\bin\javaw.exe"
mklink javaws.exe "C:\Program Files\Java\jdk1.8.0_20\bin\javaws.exe"
This now works for me.
这现在对我有用。
回答by Jitesh Beniwal
This will solve all problems relating to Java and environment variables:
这将解决与 Java 和环境变量相关的所有问题:
- Make your way to Windows' Environment Variables dialog.
- Under System variables, select the variable named Path. Click Edit...
Remove the entry that looks like:
C:\ProgramData\Oracle\Java\javapath
Add the path of your JDK/JRE's
bin
folder.- Don't forget to set JAVA_HOME.
- 进入 Windows 的环境变量对话框。
- 在系统变量下,选择名为Path的变量。单击编辑...
删除如下所示的条目:
C:\ProgramData\Oracle\Java\javapath
添加 JDK/JRE
bin
文件夹的路径。- 不要忘记设置JAVA_HOME。
回答by Vincent Risi
Why Oracle did such a poor way to point to java is beyond me. We solved this problem by creating a new link to the JDK
为什么 Oracle 以如此糟糕的方式指向 java 是我无法理解的。我们通过创建一个指向 JDK 的新链接解决了这个问题
mklink /d C:\ProgramData\Oracle\Java\javapath "C:\Program Files\Java\jdk1.8.0_40\bin\"
The same would work for a JRE if that is all that is required.
如果只需要这些,同样适用于 JRE。
This replaces the old symlinks in C:\ProgramData\Oracle\Java\javapath
(if they existed previously)
这将替换C:\ProgramData\Oracle\Java\javapath
(如果它们以前存在)中的旧符号链接
回答by Farrukh Chishti
There must be two or more PATH variables. Try merging all of them into one using semi-colon (;)
必须有两个或多个 PATH 变量。尝试使用分号 (;)
回答by john godfrey
I got the same after installing java8 from a non-permissioned account. To fix I simply reinstalled from admin user account. This created the quoted directory with file links to java exes.
从未经许可的帐户安装 java8 后,我得到了相同的结果。要修复我只是从管理员用户帐户重新安装。这创建了带有指向 java exe 的文件链接的引用目录。
回答by Murari Goswami
I had also similar problem where by I had to un-install JDK 1.8 and needed jdk 1.7. What i did was removed the symbolic links from the javapath and then imported the shortcuts of java, javaw, javaws from the bin directory to the javapath folder. However, I found some permission issues in the enterprise laptop where by I did not have the privilege to modify/ update this directory. I had given appropriate permission from the administrator and there by resolved it.
我也有类似的问题,我不得不卸载 JDK 1.8 并需要 jdk 1.7。我所做的是从javapath中删除符号链接,然后将java、javaw、javaws的快捷方式从bin目录导入到javapath文件夹中。但是,我在企业笔记本电脑中发现了一些权限问题,因为我没有权限修改/更新此目录。我已经从管理员那里获得了适当的许可,并在那里解决了它。
回答by roblogic
If you're on a corporate PC that's fairly restricted by group policy, this might work....
如果您使用的是受组策略相当限制的公司 PC,这可能会奏效....
Assuming that
假如说
- your Windows
PATH
includesC:\ProgramData\Oracle\Java\javapath
- you have JDK installed to
C:\Program Files\Java\jdk1.8.0_60\bin
- 您的 Windows
PATH
包括C:\ProgramData\Oracle\Java\javapath
- 你已经安装了JDK
C:\Program Files\Java\jdk1.8.0_60\bin
Then create the following text file mklink.bat
and put it on your desktop:
然后创建以下文本文件mklink.bat
并将其放在桌面上:
rem mklink.bat
mklink /d C:\ProgramData\Oracle\Java\javapath "C:\Program Files\Java\jdk1.8.0_60\bin"
pause
Now right-click it and choose "Run as Administrator". Provide admin credentials. The script should report success. Now you can compile or run Java.
现在右键单击它并选择“以管理员身份运行”。提供管理员凭据。脚本应该报告成功。现在您可以编译或运行 Java。
回答by Vandana
This problem exists when you upgrade from one version to another.because jdk is not automatically upgraded.
从一个版本升级到另一个版本时会出现这个问题,因为jdk不会自动升级。
For the same you can change the environmental varibles. In system variables look for the PATHand add the jdk bin location in the front of the string(not at the back). Once you have done that check in CMD if "java" and "javac" works. if it works, again go to system variables. add "CLASSPATH" A the variable and set value " . c:\Program Files\Java\jdk1.8.0_91\lib;"
同样,您可以更改环境变量。在系统变量中查找PATH并在字符串的前面(而不是在后面)添加 jdk bin 位置。如果“ java”和“ javac”有效,则在CMD中完成该检查后。如果有效,请再次转到系统变量。添加“ CLASSPATH”A变量和设置值“ .c:\Program Files\Java\jdk1.8.0_91\lib;”