检查 Java 版本时出错:找不到 java.dll
为什么我会得到这个?我该如何修复它?
C:\Users\ash>java version
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'
has value '1.7.0_01', but '1.7' is required.
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(19)
重新安装所有 JDK 的公认解决方案有点苛刻。
我也遇到过这个问题,这是我的 2 美分:
自从我安装了 JDK 8 并且仍然安装了 JDK 6 以来,这个问题就开始发生。我需要我正在从事的不同项目。
我注意到我同时拥有一个用户和一个系统
%JAVA_HOME%
,因此我删除了我的用户%JAVA_HOME%
变量,只留下了系统变量。我还注意到,在我的 Oracle 安装中存在一些 Java 可执行文件,并且我相信这些可执行文件会发生冲突,因为我的 Oracle 和 Java 安装都在我的
%PATH%
变量中。我从
%PATH%
变量中删除了所有 Java 路径,只将%JAVA_HOME%\bin
保留在变量的开头,以避免与 Oracle 安装发生任何冲突。The accepted solution for Reinstalling ALL JDKs was a bit harsh.
I too experienced this problem and here is my 2 cents:
This problem started happening since I installed JDK 8 and still had JDK 6 installed. I need for different projects I'm working on.
I noticed I had both a User and a System
%JAVA_HOME%
, so I removed my User%JAVA_HOME%
variable and left only the system one.I also noticed that in my Oracle installation there was some Java executables and I believe those where the ones conflicting since both my Oracle and Java installations were in my
%PATH%
variable.I removed all Java paths from my
%PATH%
Variable and only left the%JAVA_HOME%\bin
at the start of the variable for avoiding any conflicts with the Oracle installation.安装java 1.8后我遇到了类似的问题。
要解决此问题,请转到高级系统设置 -->路径并删除
C:\ProgramData\Oracle\Java\javapath;
I had a similar issue after installing the java 1.8.
To fix this go to Advance System setting --> path and remove
C:\ProgramData\Oracle\Java\javapath;
去除
像魅力一样工作
Removing
work like charm
重新安装 JDK 并在 JDK 上设置系统变量 JAVA_HOME。 (例如C:\tools\jdk7)
并将 JAVA_HOME 变量添加到 PATH 系统变量中,
在命令行中键入
并
验证安装是否成功完成。
Reinstall JDK and set system variable JAVA_HOME on your JDK. (e.g. C:\tools\jdk7)
And add JAVA_HOME variable to your PATH system variable
Type in command line
and
To verify whether your installation was done successfully.
安装 java 10.0 后我遇到了类似的问题
要解决此问题,请转到高级系统设置 -->路径并删除
C:\ProgramData\Oracle\Java\javapath;
I had a similar issue after installing the java 10.0
To fix this go to Advance System setting --> path and remove
C:\ProgramData\Oracle\Java\javapath;
我必须从冲突的“路径”中删除公共文件 javapath,才能使其正常工作。现在幸运的是 java -version 工作得很好。
I had to remove the Common Files javapath from the 'Path' that was conflicting, in order to make it work. Now thankfully the java -version works just fine.
确保您的 JDK
Path
变量指向\bin
文件夹并且位于列表顶部,因为它始终使用第一个匹配项。通过将其移至顶部,您可以确保首先没有其他路径匹配。如果有任何其他条目包含名为 java 的文件(例如 C:\ProgramData\Oracle\Java\javapath),它将针对该文件而不是 JDK 中的 java 文件运行命令。除非您的文件因某种原因损坏或损坏,否则无需重新安装整个 JDK。
Make sure your JDK
Path
variable is directing to the\bin
folder and is at the top of the list, because it always uses the first match. By moving it to the top you can make sure that no other path is matched first.If there's any other entry that has a file called java (such as
C:\ProgramData\Oracle\Java\javapath
) it will run the command against that file instead of the java file in your JDK. There's no need to reinstall the entire JDK unless your files are corrupt or damaged for some reason.当您的“Java Runtime Environment”注册表项丢失或与安装的 JDK 不匹配时,通常会在 Windows 中出现此问题。不匹配可能是由于多个 JDK 造成的。
解决步骤:
打开“运行”窗口:
按窗口+R
打开注册表窗口:
输入
regedit
并输入。转到:
\HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\
如果 JavaSoft 中不存在 Java Runtime Environment,则创建一个新密钥并命名为 Java Runtime Environment。
对于 Java 运行时环境,创建“CurrentVersion”字符串键并提供适当的版本作为值:
创建一个新的1.8 的子项。
对于 1.8,创建一个名为 JavaHome 且值为 JRE home 的字符串键:
Ref: https://mybindirectory.blogspot.com/2019/05/error-could-not-find-javadll.html
This problem generally occurs in Windows when your "Java Runtime Environment" registry entry is missing or mismatched with the installed JDK. The mismatch can be due to multiple JDKs.
Steps to resolve:
Open the Run window:
Press windows+R
Open registry window:
Type
regedit
and enter.Go to:
\HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\
If Java Runtime Environment is not present inside JavaSoft, then create a new Key and give the name Java Runtime Environment.
For Java Runtime Environment create "CurrentVersion" String Key and give appropriate version as value:
Create a new subkey of 1.8.
For 1.8 create a String Key with name JavaHome with the value of JRE home:
Ref: https://mybindirectory.blogspot.com/2019/05/error-could-not-find-javadll.html
我编辑了路径,将 Oracle JDK 放在路径的开头,并修复了该问题。
I edited my path to put the Oracle JDK at the start of the path and that fixed it.
问题:
我们的 Windows 2012 服务器也遇到了同样的问题。我们使用了JAVA_HOME环境系统变量,我们在PATH中使用了这样的设置:...%JAVA_HOME%/bin;...
并且 PATH 中没有其他与 java 相关的设置。
问题是 JAVA_HOME 变量值的末尾有一个空格。就像“C:\Program Files\Java\Jdk 1.8.0_172”一样,%JAVA_HOME%/bin 意味着“C:\Program Files\Java\Jdk 1.8.0_172 \bin”。因为该值被空格分割,并且系统尝试在“C:\Program Files\Java\Jdk 1.8.0_172”中查找 java.exe,但显然不是。
解决方案是:删除 JAVA_HOME 值末尾的空格!
Problem:
We had the same problem in our Windows 2012 server. We used JAVA_HOME environmental system variable, an we used in the PATH this kind of settings: ...%JAVA_HOME%/bin;...
and no other java related settings was in the PATH.
The problem was we had a space at the end of the value of the JAVA_HOME variable. Like 'C:\Program Files\Java\Jdk 1.8.0_172 ' so the %JAVA_HOME%/bin meant 'C:\Program Files\Java\Jdk 1.8.0_172 \bin'. So because the value was split by space and the system tried to find java.exe at 'C:\Program Files\Java\Jdk 1.8.0_172' where it is obviously not.
Solution was: Delete the space from the end of value of the JAVA_HOME !
此过程会清除所有 java 痕迹,然后安装新的 java。
注意:当进行多次安装和卸载时,会出现此问题。
This process cleans up all the traces of java and then install fresh java.
Note: This issues occurs when there is multiple installation and uninstall done.
您可以在 64 位环境中使用 32 位版本的 java。
从 HKLM\Software\JavaSoft 导出注册表配置单元并导入到 HKLM\Software\Wow6432Node\JavaSoft。对于 1.6,我只需要 JavaHome 和 RuntimeLib 值。
You could be using a 32 bit version of java on a 64 bit environment.
Export the registry hive form HKLM\Software\JavaSoft and import into HKLM\Software\Wow6432Node\JavaSoft. For 1.6 I only needed JavaHome and RuntimeLib values.
不幸的是,以上这些都不适合我。
当我卸载计算机上安装的旧 JDK 版本时,该错误得到解决。我只需使用“卸载或更改程序”工具(在控制面板下)即可完成此操作。
None of the above worked for me, unfortunately.
The error solved when I uninstalled the old JDK versions that were installed on my computer. I did it simply with the "Uninstall or change a program" tool (under the Control Panel).
我从 PATH 变量中删除了“C:\Program Files (x86)\Heroku\bin”,问题就消失了。我认为这可能是 Heroku 需要不同版本的 Java。因此,请检查 PATH 变量中的所有目录,删除可能存在冲突的目录。
I removed the "C:\Program Files (x86)\Heroku\bin" from PATH variable and the problem has gone. I think it is probably the Heroku require different version of Java. So check all directories in your PATH variable, remove the possible ones may have confliction.
如果在完成环境变量中的所有设置后,您在 cmd 中遇到此错误,并出现另一个错误“无法找到运行时环境”。然后你只需要在jdk文件夹中运行jre.exe并重新安装它,然后通过java -version命令重新检查它。希望它能帮助你。
If you face this error in cmd with another error as "could not find runtime environment" after you have done all settings in Environment Variable. Then you just need to run jre.exe in your jdk folder and reinstall it and then recheck it by java -version command. Hope it will help you.
“C:\Windows\System32\java.exe”重命名为“C:\Windows\System32\java_old.exe”
java -version
完成。
"C:\Windows\System32\java.exe" to "C:\Windows\System32\java_old.exe"
java -version
done.
就我而言,注册表信息是正确的,并且通过执行以下操作解决了问题:
1)将 JAVA_HOME 设置为 jdk - set JAVA_HOME=C:\Program Files\Java\\bin
2) 将 PATH 设置为 jre - set PATH="C:\Program Files\Java\\bin"
In my case the regedit information was correct and the problem was solved by doing the below:
1) setting JAVA_HOME to jdk - set JAVA_HOME=C:\Program Files\Java\\bin
2) setting PATH to jre - set PATH="C:\Program Files\Java\\bin"
添加如图所示的需求路径并删除 C:\ProgramData\Oracle\Java\javapath; 后。不要忘记重新打开编辑器。
after adding the requirements path as illustrated up and deleting C:\ProgramData\Oracle\Java\javapath;. don't forget to reopen your editor.
转到 CMD 并输入以下内容:
SET PATH=C:\Program Files\Java\jdk1.8.0_291\bin
(这里jdk1.8.0_291代表你的java版本,它可能与你不同)
Go to CMD and type the following:
SET PATH=C:\Program Files\Java\jdk1.8.0_291\bin
(here jdk1.8.0_291 represents your java version, it may differ for you)