There is also a function for the primitive "long" type to set individual elements in the JNI. So I believe you want to have something like this
unsigned int* cIntegers = getFromSomewhere(); int elements = sizeof(cIntegers) / sizeof(int); jfieldID jLongArrayId = env->GetFieldID(javaClass, "longArray", "[J"); jlongArray jLongArray = (jlongArray) env->GetObjectField(javaObject, jLongArrayId); for (unsigned int i = 0; i < elements; ++i) { unsigned int cInteger = cIntegers[i]; long cLong = doSomehowConvert(cInteger); env->SetLongArrayElement(jLongArray, i, (jlong) cLong); }
if the long array in java is called longArray and the java class is stored in the jclass JNI javaClass .
source share