Yes, it is possible. There is an example here that does exactly what you want. You will need to create the array and the strings from the JNI side (akin of invoking new String(char[])
) in java. Both Unicode and UTF-8 are supported (there is a JNI function set for each one).
#include <jni.h>
#include "ArrayHandler.h"
JNIEXPORT jobjectArray JNICALL Java_ArrayHandler_returnArray
(JNIEnv *env, jobject jobj)
{
jobjectArray ret;
int i;
char *message[5]= {"first",
"second",
"third",
"fourth",
"fifth"};
ret= (jobjectArray)env->NewObjectArray(5,
env->FindClass("java/lang/String"),
env->NewStringUTF(""));
for(i=0;i<5;i++) {
env->SetObjectArrayElement(
ret,i,env->NewStringUTF(message[i]));
}
return(ret);
}