In Java, an array is an object. Therefore, to transfer an array of bytes from C or C ++ to java, you need to create an instance of jbyteArray and return it. Instead of array C. To solve this problem, see the following code:
JNIEXPORT jbyteArray JNICALL Java_Test_returnArray (JNIEnv *env, jobject This) { jbyte a[] = {1,2,3,4,5,6}; jbyteArray ret = env->NewByteArray(6); env->SetByteArrayRegion (ret, 0, 6, a); return ret; }
Based on this link
source share