I am using Java native function -
public native ArrayList parseXML();
In C++ my native function -
vector<
The method is:
bool add(Object);
So the signature is:
"(Ljava/lang/Object;)Z"
More at: http://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/types.html#wp276
vector <char*> vec;
jclass clazz = (*env).FindClass("java/util/ArrayList");
jobject obj = (*env).NewObject(clazz, (*env).GetMethodID(clazz, "<init>", "()V"));
for (int n=0;n<vec.size();n++)
{
char* str = (char*) static_cast<char*>(vec[n]);
jstring _str = (*env).NewStringUTF(str);
(*env).CallBooleanMethod(object, (*env).GetMethodID(clazz, "add", "(Ljava/lang/Object;)Z"), _str);
}
return obj;
You would have to create a wrapper for the ArrayList in C++. Something like:
vector <char*> vec;
jclass clazz = (*env).FindClass("java/util/ArrayList");
jobject obj = (*env).NewObject(clazz, (*env).GetMethodID(clazz, "<init>", "()V"));
for (int n=0;n<vec.size();n++)
{
char* str = (char*) static_cast<char*>(vec[n]);
jstring _str = (*env).NewStringUTF(str);
(*env).CallVoidMethod(object, (*env).GetMethodID(clazz, "add", "(java/lang/Object)V"), _str);
}
return obj;
for further information see:
http://download.oracle.com/javase/1.4.2/docs/guide/jni/spec/functions.html