Hi,
Has anyone had much success with this? I'm trying to compile a C++ file in Visual C++ 6.0 that will access a function on a
Java object. I'm using JDK 1.3.
By finding some online examples and attempting to follow them, I've got code like:
#include <jni.h>
void
test()
{
JavaVM *jvm; /* denotes a Java VM */
JNIEnv *env; /* pointer to native method interface */
JDK1_1InitArgs vm_args; /* JDK 1.1 VM initialization arguments */
vm_args.version = 0x00010001; /* New in 1.1.2: VM version */
/* Get the default initialization arguments and set the class
* path */
JNI_GetDefaultJavaVMInitArgs(&vm_args);
// vm_args.classpath = ...;
/* load and initialize a Java VM, return a JNI interface
* pointer in env */
JNI_CreateJavaVM(&jvm, &env, &vm_args);
/* invoke the Main.test method using the JNI */
jclass cls = env->FindClass("Main");
jmethodID mid = env->GetStaticMethodID(cls, "test", "(I)V");
env->CallStaticVoidMethod(cls, mid, 100);
}
However, trying to compile this gives:
error C2664: 'JNI_CreateJavaVM' : cannot convert parameter 2 from 'struct JNIEnv_ ** ' to 'void ** '
Every example I can find seems to create the JVM in the same way - has anyone any ideas how I can get round this?
Kind Regards,
Si