Search code examples
javac++multidimensional-arrayjava-native-interface

Two dimensional arrays in JNI


I have started working with JNI. in which i want to return two dimensional array from a cpp method and retrive in java. I have got the information for single dimensional array as follow:

JNIExport jint JNICALL Java_IntArray_sumArray(JNIEnv *env, jobject obj)

can any one specify how to return two dimensional arrays from cpp and retrieve in java jni?

EDIT i have tried following

JNIEXPORT jobjectArray JNICALL
 Java_ObjectArrayTest_initDouble2DArray(JNIEnv *env,
                                    jclass cls,
                                    )
 {
     jobjectArray result;
     int i;
     jclass doubleArrCls = **(*env)**->FindClass(env, "[D");
...
 }

but it gives an error that error C2819: type 'JNIEnv_' does not have an overloaded member 'operator ->'


Solution

  • Please go through this post for understanding how to return 2D arrays from C++

    C++-2D array