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