Invoking a JVM
Hello!
I've got a java gui and a c++ engine that i need to connect. I would like to be able to, from java, call a native function that will create a c++ object, which in one of its methods, will creates a jvm and calls a java function. Is this possible? Currently, i am getting -1 value for my JNI_CreateJavaVM call.
Also, in C++ I am creating a dll (so that it can be loaded by java). Am I correct when I add jvm.lib? Or do I need to directly load the jvm.dll Thanks!
Here is my where I try to invoke the jvm (I am using Visual C++ and using jdk1.3):
JavaVMInitArgs vm_args;
char *m_classPath;
JavaVMOption cp[2];
cp[0].optionString = "-Djava.class.path=c:\\mypath";
cp[1].optionString = "-Djava.class.path=D:\\myclasses";
vm_args.version = JNI_VERSION_1_2;
vm_args.nOptions = 2;
vm_args.ignoreUnrecognized = TRUE;
vm_args.options = cp;
jint ret = JNI_CreateJavaVM(&jvm, (void **) &env, &vm_args);
if (ret < 0) {
fprintf(stderr, "Can't create JVM. Error: %ld\n", ret);
}

