How to fix could not find java.dll error real quick!



java dll Windows ERROR : could not find java dll

Trouble installing multiple versions of Java ? is your JVM fails to launch with could not find java dll error?. Here are the step by step procedure on how to reproduce java dll issue and fix the same. Please note could not find java dll issue most probably occurs when more than one java version is installed on the client system.



Step By Step Procedure to Reproduce - java.dll not found ERROR :



Downloand Java JRE versions you would like to install. In this case we try to install Java 8 JRE first and Java 9 JRE later.

  1. Install a Java 8 JRE
  2. Open a windows command prompt and type java, the JVM should launch normally and give the usage instructions
  3. Install a Java 9 JRE
  4. Type java, the JVM should launch normally and give the usage instructions



Could not find java.dll ERROR Stackstrace :



Ideally the JVM version 9 should launch correctly but the JVM fails to launch with below ERROR Message on the Command prompt.

Command Prompt ERROR : could not find java dll

>java -version
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.
Error: could not find java.dll error: could not find java se runtime environment.

>java
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion' has value '1.8', but '1.7' is required. Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.

or

error: registry key 'software\javasoft\java runtime environment'\currentversion' has value '1.8', but '1.7' is required. error: could not find java.dll error: could not find java se runtime environment.




# Resolving java.dll not found error



Steps to fix Could not find Java.dll error if you are using Oracle JDK.



If you are using Oracle JDK, Please follow the below steps:

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.



Steps to fix Could not find Java.dll error if you are using OpenJDK



If you are using OpenJDK, this issue is a bug in OpenJDK 9 and is fixed in the latest releases. Please use the latest version of OpenJDK Java 9. You should be able to use Java 8 and Java 9 on the same client system without any issues. For clean install please refer Java Installation on Windows

Note:


If above steps fail to resolve the issues then this is most like an issue with environment variable path setup pointing to the correct version. Please make sure that there is no ambigous environment variable in the path.


Refer below links from Oracle for details:


Java JRE/JDK Install
Java Environment Paths
JAVA_HOME Path


More details about this Bug in OpenJDK -




Here is the summary of the proposed / implemented fix in OpenJDK:

Installer creates symlinks for java.exe and some other Java binaries in C:\ProgramData\Oracle\Java\javapath folder. This folder is added to system wide PATH variable. So when user types "java.exe -version", the symlink from C:\ProgramData\Oracle\Java\javapath folder is executed. Launcher calls GetJREPath() function from jdk/src/java.base/windows/native/libjli/java_md.c to get path to java.dll which is the JVM itself. GetJREPath() calls GetApplicationHome(). GetApplicationHome() calls GetModuleFileName() WIN API. It returns path to sysmlink, i.e. "C:\ProgramData\Oracle\Java\javapath\java.exe". Logic of GetJREPath() tries to find sibling java.dll. It fails as we don't copy all bits from JRE bin folder of installed java to "C:\ProgramData\Oracle\Java\javapath" folder. GetJREPath() fallbacks to logic that tries to get path to installed JRE from the Registry. This trick woks for 8u. However, in 9 and Verona this fallback logic was dropped with JDK-8081824 fix. The proposed solution is to add extra processing of result of GetModuleFileName() call in GetApplicationHome(). The extra processing should detect in the running module is a symlink. It it is, GetApplicationHome() should return target of the symlink and not the path to symlink itself.



Please refer the below openjdk bugs for details.



Error: could not find java.dll
java.exe will not execute correctly. java.dll not found





Read Next :