6

When running "java -version" on command prompt Windows 7, i get this:

Error: opening registry key 'Software\JavaSoft\Java Runtime Environment'
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.

I have already checked environment variables:

JAVA_HOME = C:\Program Files\Java\jdk1.8.0_212\bin

And PATH includes "%JAVA_HOME%

I have also tried deleting files : java.exe, javaw.exe and javaws.exe in ProgramData\Oracle\JAVA\Javapath However, they won't delete. Even though I am an administrator.

I have also checked C:\Windows\System32 and C:\Windows\SYSWOW64 and didnt find java.exe, javaw.exe or javaws.exe to delete.

What else can I try?

monkey123
  • 183
  • 1
  • 3
  • 11
  • 2
    Possible duplicate of [Error when checking Java version: could not find java.dll](https://stackoverflow.com/questions/9313353/error-when-checking-java-version-could-not-find-java-dll) – George Z. Jul 28 '19 at 21:06
  • @GeorgeZ I Tried all solutions suggested on that page, none worked for me – monkey123 Jul 28 '19 at 21:55
  • Have you tried removing the ProgramData\Oracle location from your PATH? – Mark Rotteveel Jul 29 '19 at 15:34
  • @MarkRotteveel yes – monkey123 Jul 29 '19 at 17:12
  • 1
    1. Do you have multiple Java installed? 2. What is there in registry key? Does the version specified in the registry key match with your JDK/JRE folder name? 3. `JAVA_HOME` should be the path excluding `bin` and PATH should include `bin` as `%JAVA_HOME%/bin` 4. Are there duplicate entries in `PATH` and also duplication between user and system variables? 5. Can you directly go (cd) to JDK/JRE bin directory where `java` executable is present and run `java -version`? – fiveelements Jul 29 '19 at 17:34
  • @fiveelements only one Java installed. Not sure where the registry key is, where can i find it? I fixed the paths to match what you said. and when i do java -version in the jdk/jre bin directory it displays the version – monkey123 Jul 29 '19 at 19:30
  • @fiveelements for the path is it %JAVA_HOME%/bin or %JAVA_HOME%\bin? (forward slash or back slash) – monkey123 Jul 29 '19 at 19:32
  • In Windows backward slash is used for directory path so, use `%JAVA_HOME%\bin'. Use `regedit' command to open the registry and look for the key you mentioned in your question. Cleanup/correct it if you see discrepancy. – fiveelements Jul 29 '19 at 19:35
  • I hope you have taken care of System32 and SysWOW64 directories. Ensure to launch a new command prompt after changing environment variables. – fiveelements Jul 29 '19 at 19:39
  • @fiveelements The registry key 'Software\JavaSoft\Java Runtime Environment' looks to be missing. And yes launching new command each time i make a change – monkey123 Jul 29 '19 at 19:46
  • The key full path is: `HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\CurrentVersion`. – fiveelements Jul 29 '19 at 19:51
  • @fiveelements JavaSoft folder is missing from that location – monkey123 Jul 29 '19 at 19:54
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/197181/discussion-between-monkey123-and-fiveelements). – monkey123 Jul 29 '19 at 20:03

2 Answers2

1
  1. Do you have multiple Java installed?
  2. What is there in registry key? Does the version specified in the registry key match with your JDK/JRE folder name? Use regedit command to open the registry and look for the key you mentioned in your question (HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\CurrentVersion). Cleanup/correct the version if you see a discrepancy.
  3. JAVA_HOME should be the path excluding bin and PATH should include bin as %JAVA_HOME%\bin
  4. Are there duplicate entries in PATH and also duplication between user and system environment variables?
  5. Can you directly go (cd) to JDK/JRE bin directory where java executable is present and run java -version?
  6. Lastly, I hope you looked at C:\Windows\System32 and C:\Windows\SYSWOW64 directories and removed java.exe and related files.
fiveelements
  • 3,649
  • 1
  • 17
  • 16
1

This error also comes when the software you are using is of 32-bit and you have a 64-bit version of Java installed which is not compatible with the existing softwares where you want to work. You may also uninstall 64-bit and install the 32-bit version which will resolve the issue.

Dada
  • 6,313
  • 7
  • 24
  • 43