In my Java code I have a 2D float array float[x][4] floatArray. Here x can be between 1 and 25. I have to pass this 2D float array to a C++<
Something like this should work:
jboolean MyJNIMethod(JNIEnv * env, jobject obj, jobjectArray myArray)
{
int len1 = env -> GetArrayLength(myArray);
jfloatArray dim= (jfloatArray)env->GetObjectArrayElement(myArray, 0);
int len2 = env -> GetArrayLength(dim);
float **localArray;
// allocate localArray using len1
localArray = new float*[len1];
for(int i=0; iGetObjectArrayElement(myArray, i);
jfloat *element=env->GetFloatArrayElements(oneDim, 0);
//allocate localArray[i] using len2
localArray[i] = new float[len2];
for(int j=0; j
Note that this is outline. It won't compile ;) (I wrote it in this overstacks' editor)
In your class you should declare native method:
public native void myJNIMethod(float[][] m);
and in your c code corresponding:
JNIEXPORT jboolean JNICALL Java_ClassName_methodName (JNIEnv *, jobject, jobjectArray);
Here is JNI array operations documentation.