我在一个dll中加载JVM但是它失败了(在它失败的代码中指出)。我在exe中尝试了相同的代码并且工作正常。
JavaVMInitArgs vm_args; /* JDK 1.1 VM initialization arguments */
JNIEnv *env;
JavaVMOption options;
options.optionString = "-Djava.class.path=C:\\Core\\bin\\otk-1.4.1-with-dependencies.jar";
vm_args.version = JNI_VERSION_1_6;
vm_args.nOptions = 1;
vm_args.options = &options;
vm_args.ignoreUnrecognized = 0;
jvm_dll = LoadLibrary("C:\\Program Files\\Java\\jdk1.6.0_23\\jre\\bin\\server\\jvm.dll");
if(jvm_dll == NULL)
{
getManager()->log( "InitialiseJava::Can't Load JVM DLL.", HIGH_IMPORTANCE );
return false;
}
JNI_CreateJavaVM_ptr = (JNI_CreateJavaVM_func)GetProcAddress(jvm_dll, "JNI_CreateJavaVM");
if(JNI_CreateJavaVM_ptr == NULL)
{
getManager()->log( "InitialiseJava::Can't create JVM.", HIGH_IMPORTANCE );
return false;
}
int ret = JNI_CreateJavaVM_ptr(jvm, (void**)&env, &vm_args); // fails here
if(ret < 0)
{
getManager()->log( "InitialiseJava::Unable to call JVM.", HIGH_IMPORTANCE );
return false;
}
请帮忙。