我有以下简单的jni应用程序:
jobjectArray ListItems(JNIEnv *env, jobject self, jstring library)
{
jclass c = env->FindClass("java/lang/String");
jobjectArray a = env->NewObjectArray(2, c, 0);
env->SetObjectArrayElement(a, 0, env->NewStringUTF("text1"));
env->SetObjectArrayElement(a, 1, env->NewStringUTF("text2"));
return a;
}
int main()
{
...
...*load and initialize Java VM and JNI interface*
...
JNINativeMethod m[1];
m[0].fnPtr = ListItems;
m[0].name = "listItems";
m[0].signature = "(Ljava/lang/String;)[Ljava/lang/String;";
env->RegisterNatives(myJavaClass, m, 1);
}
当我编译如下代码时,它会告诉我“错误:从jobjectarray到void的转换无效”
g++ -I"JNI\include" -I"JNI\include\win32" test.cpp -o test.exe
1条答案
按热度按时间yhuiod9q1#
正如@michael所说,只需要一个空*铸造: