Fix Error Could not find Java SE Runtime Environment

When trying to open a Java .jar file through the command prompt, such as using the command “Java -Jar xxxx.jar”, you might encounter the following error message:

Error: opening registry key ‘Software\JavaSoft\JRE’

Error: could not find java.dll

Error: Could not find Java SE Runtime Environment.

This could be due to several factors, including but not limited to:

  • Corrupted registry
  • Missing Java path in your Environment Variables
  • Java installation folder being moved

For example, we encountered this issue when updating Java SE to the latest version – we likely previously had a 32-bit Java installation, and when running the 64-bit Java installer, our Java path changed.

Error output when trying to run Java commands in Command Prompt.

Luckily, this is fairly easy to fix, as it just requires addressing one of the above problems with the appropriate solution. Follow our steps below to get your Java commands via command prompt working again, and leave a comment in the comments section if you encounter any further issues (or know of a better solution).

  1. Delete all previous versions of Java (using “Programs and Features” uninstall process). If java folder is remains in “C:/Program Files/…”, please delete it.
  2. Clean up your registry (delete your java key):
  3. Go to Start and then Run
  4. Type in ‘regedit’ in the edit field
  5. Go to HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Uninstall
  6. Under this Uninstall folder you will find many registry entries within curly brackets.
    Regedit uninstall pathway.
  7. Click on Edit tab and then Find
  8. Note: Highlight Uninstall folder before performing search for particular registry.
  9. Enter version string as value to find corresponding registry entry to be deleted.
  10. Once you find registry key, highlight that key and then Right click on it and choose Delete
  11. Confirm the delete and click Yes

Steps for finding registry keys for any version of Java 7

Follow format 7.0.xxx
where xxx can be 100, 120, 130, 140 and so on.
for example:

  • Type 7.0.100 in search field, finds registry key for Java7 update 10
  • Type 7.0.120 in search field, finds registry key for Java7 update 12
  • Type 7.0.180 in search field, finds registry key for Java7 update 18

Steps for finding registry keys for any version of Java 6

Follow format 6.0.xxx
where xxx can be 100, 120, 130, 140 and so on.
for example:

  • Type 6.0.100 in search field, finds registry key for Java6 update 10
  • Type 6.0.120 in search field, finds registry key for Java6 update 12
  • Type 6.0.180 in search field, finds registry key for Java6 update 18

Steps for finding registry keys for any version of Java 1.5

Follow format 1.5.0.xxx
where xxx can be 100, 120, 130, 140 and so on.
for example:

  • Type 1.5.0.100 in search field, finds registry key for jre1.5.0_01
  • Type 1.5.0.120 in search field, finds registry key for jre1.5.0_12
  • Type 1.5.0.180 in search field, finds registry key for jre1.5.0_18
  • Steps for finding registry keys for any version of Java 1.4

Follow format 1.4.2_xxx
where xxx can be 01, 12, 13, 14 and so on.
for example:

  • Type 1.4.2_01 in search field, finds registry key for jre1.4.0_01
  • Type 1.4.2_12 in search field, finds registry key for jre1.4.0_12
  • Type 1.4.2_18 in search field, finds registry key for jre1.4.0_18

Reinstall Java and set system variable JAVA_HOME to your JRE (or JDK) path.

Eg:

JAVA_HOME - C:\Program Files\Java\jdk1.7.0_71

Path - C:\Program Files\Java\jdk1.7.0_71\bin

 

You can check if this was a successful solution with the following commands

echo %JAVA_HOME%

java -version

Manually open command window to Java pathway.As a side note, you can also launch a command prompt directly from within the Java folder – navigate to your C:\Program Files\Java\bin folder (or wherever your Java is installed), hold Shift + Right click inside the window, and click “Open a command window here”.

ABOUT THE AUTHOR

Kamil Anwar


Kamil is a certified MCITP, CCNA (W), CCNA (S) and a former British Computer Society Member with over 9 years of experience Configuring, Deploying and Managing Switches, Firewalls and Domain Controllers also an old-school still active on FreeNode.