简体   繁体   English

找不到java.exe

[英]Cannot find java.exe

I am trying to launch a .bat file but I get the error 我正在尝试启动.bat文件,但出现错误

System cannot find the file C:\\ProgramData\\Oracle\\Java\\javapath\\java.exe 系统找不到文件C:\\ ProgramData \\ Oracle \\ Java \\ javapath \\ java.exe

I understand that this is probably a path variable, but I have not been able to understand how to fix it, if that is the problem. 我知道这可能是路径变量,但是如果出现问题,我还无法理解如何解决它。

Thanks in advance. 提前致谢。

First of all, the path that you provided ie C:\\ProgramData\\Oracle\\Java\\javapath\\java.exe doesn't appear to be correct. 首先,您提供的路径C:\\ProgramData\\Oracle\\Java\\javapath\\java.exe似乎不正确。 It should point to either JRE or JDK folder that you (probably) have in here: 它应该指向您(可能)在此处拥有的JRE或JDK文件夹:

C:\Program Files (x86)\Java\jdk1.8.0_25\bin

In there you should at least see the following files (and hence, the addition of this bin directory to your PATH variable in the env vars): 在其中,您至少应该看到以下文件(因此,将该bin目录添加到env vars中的PATH变量中):

java.exe java.exe的

javac.exe 的javac.exe

javaw.exe javaw.exe的

javap.exe javap.exe

java.h.exe java.h.exe

java-rmi.exe Java的rmi.exe

javadoc.exe 的javadoc.exe

jarsigner.exe jarsigner.exe

jar.exe jar.exe的

If you don't see the files above, something is definitely wrong! 如果您没有看到上面的文件,那肯定是错误的! Also, even if you were using JRE (not JDK), you should still have this bin folder present, where java.exe resides. 同样,即使您使用的是JRE(不是JDK),也应该仍然存在该bin文件夹,java.exe驻留在该文件夹中。

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@ECHO OFF

:: Export java settings from registry to a temporary file
START /W REGEDIT /E %Temp%\java.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft" 


if not exist "%Temp%\java.reg" (
    START /W REGEDIT /E %Temp%\java.reg "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft"
)



if not exist "%Temp%\java.reg" (
    echo java not installed 
    exit /b 1
)



:: Find java location
FOR /F "tokens=1* delims==" %%A IN ('TYPE %Temp%\java.reg ^| FIND "INSTALLDIR"') DO SET "JAVA_HOME=%%B"
SET "JAVA_HOME=%JAVA_HOME:"=%"
SET "JAVA_HOME=%JAVA_HOME:\\=\%"
::SET JAVA_HOME
set "java=%java_home%\bin\java.exe"
"%java%" -version
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Try this to see if you can automatically can detect the java location.And if it's work you can put this at the beginning of your script and use %java% in your script (though it will decrease the performance). 尝试看一下是否可以自动检测到Java位置,如果可以,可以将其放在脚本的开头并在脚本中使用%java% (尽管这样做会降低性能)。

I had the same problem. 我有同样的问题。 Here's what worked for me: Go into your path variable and delete: C:\\ProgramData\\Oracle\\Java\\javapath\\ . 这对我C:\\ProgramData\\Oracle\\Java\\javapath\\ :进入您的path变量并删除: C:\\ProgramData\\Oracle\\Java\\javapath\\
Then add a new one called: %JAVA_HOME\\bin 然后添加一个新名称: %JAVA_HOME\\bin
This post helped: java-path-is-not-pointing-to-sdk-path-in-windows 这篇文章有帮助: Java路径不是指向Windows中的sdk路径

Edit: Sorry, I just noticed that this question was 3 years old. 编辑:对不起,我只是注意到这个问题已经3岁了。

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

相关问题 Java:系统找不到文件 C:\\ ... java.exe - Java: System cannot find the file C:\ ... java.exe 无法关闭 java.exe,JNI 调用 - Cannot close java.exe, JNI calls 系统找不到文件 C:\\ProgramData\\Oracle\\Java\\javapath\\java.exe - The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe “系统找不到文件 C:\ProgramData\Oracle\Java\javapath\java.exe” - "The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe" 找不到路径:系统找不到文件 C:\\ProgramData\\Oracle\\Java\\javapath\\java.exe - Path not Found: The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe 无法运行:系统找不到文件C:\ProgramData\Oracle\Java\javapath\java.exe - Can't run: The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe 从通过VBA启动的.bat文件运行时找不到java.exe - Cannot find java.exe when run from a .bat file launched via VBA 从 java 代码中以编程方式查找绝对 java.exe 路径 - Find absolute java.exe path programmatically from java code 查找除HeapDump和ThreadDump之外的java.exe进程的内容 - Find the content of java.exe process apart from the HeapDump and ThreadDump NLTK 找不到 java.exe(自发路径缩减) - NLTK unable to find java.exe (spontaneous path reduction)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM