CreateJavaVM returns -1
843829Jun 3 2005 — edited Jun 3 2005Hi, i have a big problem. I used c++ and i am trying to connect COM and Java objects, but CreateJavaVM returns -1. Most probably, there is a problem on the system. May the problem occur due to kernel or jdk? I check the dependency of created dll ( with a program called dependency-walker), it says msjava.dll is missing. i downloaded it paste under system32. But it returns -1 again. Please help, where the problem might be? Here is my code, thanks in advance...
JavaVM *jvm;
JNIEnv *env;
jclass mClass;
jobject myObject;
long _stdcall initJEnv(LPTSTR clss,LPTSTR libr) {
JavaVMInitArgs vm_args;
JavaVMOption options[5];
char *cls = "-Djava.class.path=";
char *lib= "-Djava.library.path=";
char *classpath = new char[strlen(clss)+strlen(cls)+1];
char *librarypath = new char[strlen(libr)+strlen(lib)+1];
strcpy(classpath,cls);
strcpy(librarypath,lib);
classpath = strcat(classpath,clss);
librarypath = strcat(librarypath,libr);
options[0].optionString = "-Djava.compiler=NONE"; /* disable JIT */
options[1].optionString = classpath; /* user classes */
options[2].optionString = librarypath; /* set native library path */
options[3].optionString = "-verbose:jni"; /* print JNI-related messages */
vm_args.version = JNI_VERSION_1_2;
vm_args.options = options;
vm_args.nOptions = 4;
vm_args.ignoreUnrecognized = true;
int res = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args);
if(res < 0){
return -1;
}
mClass= env->FindClass("java/lang/String");
return res;
}