JNI Java in C ++

I am trying to create a Java virtual machine in cplusplus using the following code:

JNIEnv *env;
JavaVMInitArgs vm_args;
JavaVMOption options[1];
options[0].optionString = "-Djava.class.path=D:\\Java Src\\TestStruct"; //Path to the java source code
vm_args.version = JNI_VERSION_1_6; //JDK version. This indicates version 1.6
vm_args.nOptions = 1;
vm_args.options = options;
vm_args.ignoreUnrecognized = 0;

int ret = JNI_CreateJavaVM(jvm, (void**)&env, &vm_args);
if(ret < 0)
    printf("\nUnable to Launch JVM\n");     

I cannot create an instance because it gives me the following error. I can compile, but it gives a runtime error like this.

Error: Error initializing the virtual machine. Unable to load own library: cannot find dependent libraries

Can someone help me in advance :)

+3
source share
1 answer

Most likely jvm.dll is not located in your PATH.

+2
source

Source: https://habr.com/ru/post/1725812/


All Articles