简体   繁体   中英

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. 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.

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

C:\ProgramData\Oracle\Java\javapath;

work like charm

Reinstall JDK and set system variable JAVA_HOME on your JDK. (eg C:\tools\jdk7)
And add JAVA_HOME variable to your PATH system variable

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

To fix this go to Advance System setting --> path and remove

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. Now thankfully the java -version works just fine.

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. 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.

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:

  1. Open the Run window:

    Press windows + R

  2. Open registry window:

    Type regedit and enter .

  3. Go to: \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.

  5. For Java Runtime Environment create "CurrentVersion" String Key and give appropriate version as value:

JRE 注册表项

  1. Create a new subkey of 1.8.

  2. For 1.8 create a String Key with name JavaHome with the value of JRE home:

    JRE 注册表项 2

Ref: 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. 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 !

  1. Uninstall Java from machine
  2. Check Java folder is deleted from Program Files
  3. Check Registry does not have any instance of Java
  4. Open system Variables and delete the ONLY java path from PATH
  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.

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. 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.

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. 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. 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.

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.

  1. rename file "C:\Windows\System32\java.exe" to "C:\Windows\System32\java_old.exe"
  2. 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"

after adding the requirements path as illustrated up and deleting 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

(here jdk1.8.0_291 represents your java version, it may differ for you)

Similar problem for me and tried all the above option, I had to install JRE of the same version to resolve the issue. Surprised after having JDK 18 still have to install JRE. Anyone suggestions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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