JNI_CreateJavaVM always returns -1

March 20th, 2009

Applies to:
JNI

Description:
Occurs while using JNI.

Cause:
Usually, the problem is that you moved or copied the jvm.dll file. The location of jvm.dll is important, it has to be in the directory /bin/classic. This jvm.dll finds the location of other DLLs relative to its current location. So if you move it, or Windows uses some other copy of jvm.dll, the JVM will not be able to find java.dll, for instance.

admin JAVA-JNI

  1. admin
    March 20th, 2009 at 10:28 | #1

    The problem manifests itself for those using the invocation API who want to keep their PATH simple, containing only \bin. You need \bin\classic;\bin in your PATH. This does not work:
    # Do not do this!
    cd jre\bin
    copy classic\jvm.dll .
    Note that on Windows you can use also use the registry key:
    HKEY_LOCAL_MACHINE\Software\JavaSoft\JRE\RuntimeLib
    to find the path to jvm.dll and load it with LoadLibrary.

  1. No trackbacks yet.