Why does a C++ JNI_CreateJavaVM() call cause an exception?

Asked 2 years ago, Updated 2 years ago, 87 views

I am using Visual Studio 2015 and I am using JNI API to use jar library in C++ code.

#include<jni.h>
...
int main() {

    JavaVM *jvm;
    JNIEnv *env;
    JavaVMInitArgs vm_args;
    JavaVMOption *options = new JavaVMOption[1];
    jint result = 0;

    options[0].optionString = "-Djava.class.path=E:/libraries/MorphemeAnalyzer/org.snu.ids.ha.jar;";
    vm_args.version = JNI_VERSION_1_6;
    vm_args.nOptions = 1;
    vm_args.options = options;
    vm_args.ignoreUnrecognized = false;

    result = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args); //Exception Occurred
    delete options;

    try
    {
        ...
    }

    jvm->DestroyJavaVM();
}

c++ jni

2022-09-22 14:22

1 Answers

I solved it. There is an exception because there is not enough space for stacks and hips.


2022-09-22 14:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.