Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

When i call JNI_CreateJavaVM , it return -1,I can not find reason.Help!

843829Oct 8 2002 — edited Oct 19 2002
Before 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 !!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 16 2002
Added on Oct 8 2002
4 comments
100 views