Java – C int arrays to java int arrays use jni

C int arrays to java int arrays use jni… here is a solution to the problem.

C int arrays to java int arrays use jni

I have a similar feature,

int * print(int count)
{
    int * myarray;
    int i=0;
    myarray = (int *)(malloc(sizeof(int))*count);
    for(i=0; i<count; i++)
    {
      myarray[i] = i;
    }   
   return myarray;
}

Now how can I use myarray in java using JNI

I’ve tried this

jintArray Java_com_example_testmyapp_MainActivity_JListPrint(JNIEnv* env, jobject thiz)
{
     return print(5);
}

In Java

int a[] = JListPrint()

But my app crashed

Please point, suggest?

Related Problems and Solutions