Wednesday, August 14, 2019

Registry Key Error When Running java -version In Windows

Running "java -version" command on a Windows machine might get the following error -

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


Error when running "java -version".

The fix is fairly simple. Type the following command -

where java

The output might be something similar -

C:\>where java
C:\Windows\System32\java.exe
D:\java\jdk-11.0.3\bin\java.exe


Determine all the places where java.exe shouldn't exist. In my case, its the System32 folder. Navigate to the folder(s) and move the different java executable files out of the directory into a temp directory.

java.exe
javaw.exe
javaws.exe


Move the executable files out of the directory.

Run "java -version" command again, and this time it should give the right version based on the environment variables on the machine.

No comments:

Post a Comment