简体   繁体   English

检查 Java 版本时出错:找不到 java.dll

[英]Error when checking Java version: could not find java.dll

why do I get this?为什么我会得到这个? How can I fix it?我该如何解决?

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.

The accepted solution for Reinstalling ALL JDKs was a bit harsh.重新安装所有 JDK 的公认解决方案有点苛刻。 I too experienced this problem and here is my 2 cents:我也遇到过这个问题,这是我的 2 美分:

This problem started happening since I installed JDK 8 and still had JDK 6 installed.自从我安装了 JDK 8 并且仍然安装了 JDK 6 后,这个问题就开始发生了。 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.我注意到我有一个 User 和一个 System %JAVA_HOME% ,所以我删除了我的 User %JAVA_HOME%变量,只留下了系统一个。

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.我还注意到,在我的 Oracle 安装中有一些 Java 可执行文件,我相信那些有冲突的可执行文件,因为我的 Oracle 和 Java 安装都在我的%PATH%变量中。

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.我从我的%PATH%变量中删除了所有 Java 路径,并且只将%JAVA_HOME%\bin留在了变量的开头,以避免与 Oracle 安装发生任何冲突。

I had a similar issue after installing the java 1.8.安装 java 1.8 后我遇到了类似的问题。

To fix this go to Advance System setting --> path and remove要解决此问题,请转到高级系统设置 --> 路径并删除

C:\ProgramData\Oracle\Java\javapath; C:\ProgramData\Oracle\Java\javapath;

Removing移除

C:\ProgramData\Oracle\Java\javapath; C:\ProgramData\Oracle\Java\javapath;

work like charm像魅力一样工作

Reinstall JDK and set system variable JAVA_HOME on your JDK.重新安装 JDK 并在 JDK 上设置系统变量 JAVA_HOME。 (eg C:\tools\jdk7) (例如 C:\tools\jdk7)
And add JAVA_HOME variable to your PATH system variable并将 JAVA_HOME 变量添加到您的 PATH 系统变量

Type in command line输入命令行

echo %JAVA_HOME%

and

java -version

To verify whether your installation was done successfully.验证您的安装是否成功。

I had a similar issue after installing the java 10.0安装 java 10.0 后我遇到了类似的问题

To fix this go to Advance System setting --> path and remove要解决此问题,请转到高级系统设置 --> 路径并删除

C:\ProgramData\Oracle\Java\javapath; C:\ProgramData\Oracle\Java\javapath;

I had to remove the Common Files javapath from the 'Path' that was conflicting, in order to make it work.我必须从冲突的“路径”中删除公共文件 javapath,才能使其正常工作。 Now thankfully the java -version works just fine.现在幸运的是java -version工作得很好。

C:\Program Files (x86)\Common Files\Oracle\Java\javapath

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.确保您的 JDK Path变量指向\bin文件夹并且位于列表顶部,因为它始终使用第一个匹配项。 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.如果有任何其他条目包含名为 java 的文件(例如C:\ProgramData\Oracle\Java\javapath ),它将针对该文件而不是 JDK 中的 java 文件运行命令。 There's no need to reinstall the entire JDK unless your files are corrupt or damaged for some reason.除非您的文件由于某种原因损坏或损坏,否则无需重新安装整个 JDK。

This problem generally occurs in Windows when your "Java Runtime Environment" registry entry is missing or mismatched with the installed JDK.当您的“Java 运行时环境”注册表项丢失或与安装的 JDK 不匹配时,通常会在 Windows 中出现此问题。 The mismatch can be due to multiple JDKs.不匹配可能是由于多个 JDK 造成的。

Steps to resolve:解决步骤:

  1. Open the Run window:打开运行窗口:

    Press windows + R窗口+ R

  2. Open registry window:打开注册表窗口:

    Type regedit and enter .键入regedit输入

  3. Go to: \HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\转到: \HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\

  4. If Java Runtime Environment is not present inside JavaSoft, then create a new Key and give the name Java Runtime Environment.如果 JavaSoft 中不存在 Java 运行时环境,则创建一个新密钥并命名为 Java 运行时环境。

  5. For Java Runtime Environment create "CurrentVersion" String Key and give appropriate version as value:对于 Java 运行时环境,创建“CurrentVersion”字符串键并给出适当的版本作为值:

JRE 注册表项

  1. Create a new subkey of 1.8.创建一个 1.8 的新子项。

  2. For 1.8 create a String Key with name JavaHome with the value of JRE home:对于 1.8,创建一个名为 JavaHome 且值为 JRE home 的字符串键:

    JRE 注册表项 2

Ref: https://mybindirectory.blogspot.com/2019/05/error-could-not-find-javadll.html参考: https ://mybindirectory.blogspot.com/2019/05/error-could-not-find-javadll.html

我编辑了我的路径,将 Oracle JDK 放在路径的开头并修复了它。

Problem: We had the same problem in our Windows 2012 server.问题:我们在 Windows 2012 服务器中遇到了同样的问题。 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.我们使用了 JAVA_HOME 环境系统变量,我们在 PATH 中使用了这种设置:...%JAVA_HOME%/bin;... 并且在 PATH 中没有其他与 java 相关的设置。

The problem was we had a space at the end of the value of the JAVA_HOME variable.问题是我们在 JAVA_HOME 变量的值末尾有一个空格。 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'.像 'C:\Program Files\Java\Jdk 1.8.0_172 ' 所以 %JAVA_HOME%/bin 的意思是 '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.因此,因为该值被空格分割并且系统试图在'C:\ Program Files \ Java \ Jdk 1.8.0_172'处找到java.exe,但显然不是。

Solution was: Delete the space from the end of value of the JAVA_HOME !解决方案是:删除 JAVA_HOME 值末尾的空格!

  1. Uninstall Java from machine从机器上卸载 Java
  2. Check Java folder is deleted from Program Files检查 Java 文件夹是否已从 Program Files 中删除
  3. Check Registry does not have any instance of Java检查注册表没有任何 Java 实例
  4. Open system Variables and delete the ONLY java path from PATH打开系统变量并从 PATH 中删除唯一的 java 路径
  5. Now install the new version again.现在再次安装新版本。
  6. Set the Path in System Variables.在系统变量中设置路径。

This process cleans up all the traces of java and then install fresh java.此过程会清理所有 java 的痕迹,然后安装新的 java。

Note: This issues occurs when there is multiple installation and uninstall done.注意:当有多个安装和卸载完成时会出现此问题。

You could be using a 32 bit version of java on a 64 bit environment.您可以在 64 位环境中使用 32 位版本的 java。 Export the registry hive form HKLM\Software\JavaSoft and import into HKLM\Software\Wow6432Node\JavaSoft.从 HKLM\Software\JavaSoft 导出注册表配置单元并导入 HKLM\Software\Wow6432Node\JavaSoft。 For 1.6 I only needed JavaHome and RuntimeLib values.对于 1.6,我只需要 JavaHome 和 RuntimeLib 值。

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Javasoft]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Javasoft\Java Runtime Environment]
"CurrentVersion"="1.6"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Javasoft\Java Runtime Environment\1.6]
"JavaHome"="C:\\Java\\jre"
"RuntimeLib"="C:\\Java\\jre\\bin\\client\\jvm.dll"

None of the above worked for me, unfortunately.不幸的是,上述方法都不适合我。 The error solved when I uninstalled the old JDK versions that were installed on my computer.当我卸载安装在我的计算机上的旧 JDK 版本时,错误解决了。 I did it simply with the "Uninstall or change a program" tool (under the Control Panel).我只是使用“卸载或更改程序”工具(在控制面板下)完成的。

I removed the "C:\Program Files (x86)\Heroku\bin" from PATH variable and the problem has gone.我从 PATH 变量中删除了“C:\Program Files (x86)\Heroku\bin”,问题就消失了。 I think it is probably the Heroku require different version of Java.我认为这可能是 Heroku 需要不同版本的 Java。 So check all directories in your PATH variable, remove the possible ones may have confliction.因此,请检查 PATH 变量中的所有目录,删除可能有冲突的目录。

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.如果在完成环境变量中的所有设置后,您在 cmd 中遇到此错误并出现另一个错误为“找不到运行时环境”。 Then you just need to run jre.exe in your jdk folder and reinstall it and then recheck it by java -version command.然后你只需要在你的jdk 文件夹中运行jre.exe并重新安装它,然后通过java -version命令重新检查它。 Hope it will help you.希望它会帮助你。

  1. rename file "C:\Windows\System32\java.exe" to "C:\Windows\System32\java_old.exe"将文件"C:\Windows\System32\java.exe" to "C:\Windows\System32\java_old.exe"
  2. CMD --> java -version CMD --> java -version -版本

done.完毕。

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" 1) 将 JAVA_HOME 设置为 jdk - 设置 JAVA_HOME=C:\Program Files\Java\\bin 2) 将 PATH 设置为 jre - 设置 PATH="C:\Program Files\Java\\bin"

after adding the requirements path as illustrated up and deleting C:\ProgramData\Oracle\Java\javapath;.在添加如图所示的需求路径并删除 C:\ProgramData\Oracle\Java\javapath; 之后。 don't forget to reopen your editor.不要忘记重新打开您的编辑器。

Go to CMD and type the following: SET PATH=C:\Program Files\Java\jdk1.8.0_291\bin转到 CMD 并键入以下内容: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) (这里的 jdk1.8.0_291 代表你的 java 版本,你可能会有所不同)

Similar problem for me and tried all the above option, I had to install JRE of the same version to resolve the issue.对我来说类似的问题并尝试了上述所有选项,我必须安装相同版本的 JRE 才能解决问题。 Surprised after having JDK 18 still have to install JRE.在拥有 JDK 18 后仍然必须安装 JRE 感到惊讶。 Anyone suggestions任何人的建议

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

相关问题 我得到的错误检查 Apache Pig 版本“错误:无法找到或加载主类 C:\\java\\lib\\tools.jar” - The error I get Which checking Apache Pig Version "Error: Could not find or load main class C:\java\lib\tools.jar" 导入项目时,Eclipse错误“无法确定Java版本” - Eclipse error 'could not determine Java version' when importing project 运行Java wsdl客户端时找不到主类错误 - Could not find main class error when running a java wsdl client 错误:无法从“15.0.2”确定 java 版本 - ERROR: Could not determine java version from '15.0.2' 错误:无法从“17.0.1”确定 java 版本 - ERROR: Could not determine java version from "17.0.1" 如何修复错误:在Windows 8.1版本中的“(null)”中找不到所需的Java(TM)2运行时版本 - How to fix error: could not find the required version of the Java(TM) 2 runtime environment in '(null)' in Windows 8.1 verson 如何解决错误:在“(null)”中找不到所需的Java(TM)2运行时环境版本 - How to fix error: could not find the required version of the Java(TM) 2 runtime environment in '(null)' Java-错误:找不到或加载主类 - Java - Error: Could not find or load main class 错误:找不到或加载主类(在Java 8中) - Error: Could not find or load main class ( in Java 8) Java:错误:找不到或加载主类 - Java: Error: Could not find or load main class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM