Rajesh Kumar J
Rajesh Kumar J

Reputation: 4795

JNI Java in c++

I am trying to create Java Virtual Machine in a cplusplus program using the code as follows:

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 am unable to create an instance as it is giving me the following error . I am able to compile but it is giving runtime error like this..

Error Output: Error occurred during initialization of VM Unable to load native library: Can't find dependent libraries

Can anybody help me thanks in advance :)

Upvotes: 3

Views: 4338

Answers (1)

Idan K
Idan K

Reputation: 20901

Most likely that jvm.dll isn't in your PATH.

Upvotes: 2

Related Questions