When i call JNI_CreateJavaVM , it return -1,I can not find reason.Help!
843829Oct 8 2002 — edited Oct 19 2002Before calling the method of java class in c++,I
must create a dynamic jvm,but ,the JNI_CreateJavaVM'
return -1(no success).
here is the source code:
1. #include <jni.h>
2.
3. #ifdef _WIN32
4. #define PATH_SEPARATOR ';'
5. #else
6. #define PATH_SEPARATOR ':'
7. #endif
8.
9. int main()
10. {
11. JavaVMOption options[1];
12. JNIEnv *env;
13. JavaVM *jvm;
14. JavaVMInitArgs vm_args;
15. long status;
16. jclass cls;
17. jmethodID mid;
18. jint square;
19. jboolean not;
20.
21. options[0].optionString = "-Djava.class.path=.";
22. memset(&vm_args, 0, sizeof(vm_args));
23. vm_args.version = JNI_VERSION_1_2;
24. vm_args.nOptions = 1;
25. vm_args.options = options;
26. status = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
}
thanks !!