50

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.
1
  • 3
    Does 'java version' works? Coz, I use 'java -version'.
    – sgowd
    Feb 16, 2012 at 14:50

19 Answers 19

47

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.

1
  • 4
    I had an errant java.exe in Windows/System32. I removed it and all is well. Feb 5, 2018 at 0:41
42

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;

1
  • 2
    Or move the entry you need higher than that one
    – DFSFOT
    May 22, 2019 at 14:21
19

Removing

C:\ProgramData\Oracle\Java\javapath;

work like charm

1
  • 1
    Had the same problem. I moved my JDK up in the list so I didn't have to remove the entry.
    – DFSFOT
    May 31, 2018 at 17:08
16

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

echo %JAVA_HOME%

and

java -version

To verify whether your installation was done successfully.

4
  • 2
    isn't variable value for JAVA_HOME supposed to be JRE?-confluence.atlassian.com/display/DOC/… Dec 16, 2014 at 6:59
  • Can you show these steps in more details for beginners? Thank you
    – F 505
    Jan 9, 2018 at 16:03
  • @committedandroider no, it's supposed to be the root folder of your JDK if I remember correctly.
    – DFSFOT
    May 31, 2018 at 17:07
  • JAVA_HOME isn't used by Java, only by IDEs, Tomcat, etc. All you need is a correct PATH setting that yields the JDK or JRE java.exe first, not some ancient dumb Windows thing.
    – user207421
    Jul 29, 2019 at 4:17
6

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;

6

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
0
5

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.

5

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 regedit entry

  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 regedit entry 2

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

2

I edited my path to put the Oracle JDK at the start of the path and that fixed it.

2

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 !

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

1

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"
1

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

0

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.

0

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.

0
  1. rename file "C:\Windows\System32\java.exe" to "C:\Windows\System32\java_old.exe"
  2. CMD --> java -version

done.

0

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"

0

after adding the requirements path as illustrated up and deleting C:\ProgramData\Oracle\Java\javapath;. don't forget to reopen your editor.

0

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)

2
  • its a temporary solution, you have do this manually every time. Jun 21, 2021 at 21:24
  • for permanent solution go to your eclipse directory and open eclipse configure file add add this two lines just before -vmargs: -vm C:\Program Files\Java\jdk1.8.0_291\bin Jun 21, 2021 at 21:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.