Pass CCArray Objects to Java

Pass CCArray Objects to Java
0.0 0



How to pass a CCArray containing list of objects to Java using JNI.

I’ve already figured how to call java function from C++ using JNI. But can’t get a way to pass an array of objects (C++ class objects) to java.

And how to get the details from that object in Java class?



Please point me to some tutorials or sample codes!



Ok… I decided to send all the object properties instead of object. So that i can get those properties in java and i’ll use it in one model class :slight_smile:

But the problem is the processing time will be more :frowning:


Maybe this posts helps :slight_smile:

Here you can see to pass a C-struct to Java as an object.
If you want to pass an array as an object you can do like

jobjectArray userArray = (jobjectArray) env->NewObjectArray(SIZEOFTHEARRAY, jclass, 0);

        if(userArray == NULL) return NULL;

        for(int i = 0; i < SIZEOFTHEARRAY; ++i)
            //Create jobject like in link

            env->SetObjectArrayElement(userArray, i,  THEJOBJECT);

            //Delete the local refs

Hope it helps :slight_smile:


Seppe R Thanks for the code… I’ll try this one.