Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

errors when trying to initialize vm_args

When i initialize JDK1_1InitArgs using JDK1_1InitArgs vm_args compiler gives me errors. I need this variable initialized to use the function JNI_CreateJavaVM.

            JavaVM *jvm;
            JNIEnv *env;
            jmethodID mid;
            JDK1_1InitArgs vm_args; // Line 47
            vm_args.version = 0x00010001; // Line 48
            JNI_GetDefaultJavaVMInitArgs(&vm_args);
            vm_args.classpath = "C:/Program Files/Java/jdk1.7.0/lib;.;";

            JNI_CreateJavaVM(&jvm, &env, &vm_args);
            env = (*jvm)->AttachCurrentThread(jvm,&env,NULL);
            jclass cls = (*env)->GetObjectClass(env,Obj);
            mid = (*env)->GetMethodID(env,cls,"callBack","(Ljava/lang/String;)V");
            (*env)->CallVoidMethodA(env,Obj,mid,(*env)->NewStringUTF(env,"1B"));

Reference

Errors :

enter image description here

Why do i get these errors ? How can i get rid of them ?

like image 881
program-o-steve Avatar asked Nov 13 '22 04:11

program-o-steve


1 Answers

JNI 1.1 is no longer supported. See a comment from HotSpot's jvm.h, right before the definition of struct JDK1_1InitArgs:

This structure is used by the launcher to get the default thread stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a version of 1.1. As it is not supported otherwise, it has been removed from jni.h

Source: http://hg.openjdk.java.net/jdk7/jdk7/hotspot/file/tip/src/share/vm/prims/jvm.h, line 1673

It appears to be impossible to create a JVM versioned 1.1 in JDK 7 -- which means that you might want to use a later version such as 1.2, or use an older JDK.

like image 107
Niv Steingarten Avatar answered Nov 16 '22 03:11

Niv Steingarten