I have a C++ dll class. I want to return a structure array to Java Applet by using a JNI method. How can I access it from Java?
(structure array contains different type of structures)
Already returned a String array---
public native String[] fun();
JNIEXPORT jobjectArray JNICALL Java_fun(JNIEnv* pEnv, jobject Pobj)
{
}
but I didn't know how to work with Structure Array.
Could anyone please tell me.
You need to build the same structure as Java objects. Copy the values from the C++ structure into the Java structure in JNI. Return the Java structure and use it as normal Java objects.
There are few good code examples from Sun at Sun: STrings and Arrays
Try it out and tell us of your progress.
You could use JavaCPP , which generates all the nasty C++ JNI code for us. Then we only need to call Pointer.position()
from Java to navigate native arrays of structures.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.