a new question: how to call just one java method.
In the codes that I showed at the beginning, the c++ codes called the
main() method of java codes. Now the question is, how to call the
normal(not main()) method:
I tried like this (do_it is the java static void method that I would
like to call from C++):
....
jmethodID get_main_id;
jmethodID get_do_it_id;
if(cls != NULL)
{
get_main_id =
env->GetStaticMethodID(cls,"main","([Ljava/lang/String

V");
get_do_it_id =
env->GetStaticMethodID(cls,"do_it","([Ljava/lang/String

V");
if(get_main_id != NULL )
{
jclass string = env->FindClass("java/lang/String");
jobjectArray args = env->NewObjectArray(0,string, NULL);
env->CallStaticVoidMethod(cls, get_main_id, args);
}
if(get_do_it_id!= NULL )
{
jclass string = env->FindClass("java/lang/String");
jobjectArray args = env->NewObjectArray(0,string, NULL);
env->CallStaticVoidMethod(cls, get_do_it_id, args);
}
}
....
These codes can be compiled and linked. But when I run it, there is
following error:
__________________________________________________ ___________________________________
Unexpected Signal : 11 occurred at PC=0x402B420F
Function=(null)+0x402B420F
Library=/usr/lib/jvm/java-1.4.2-sun-1.4.2.05/jre/lib/i386/client/libjvm.so
NOTE: We are unable to locate the function name symbol for the error
just occurred. Please refer to release documentation for possible
reason and solutions.
Current Java thread:
....
__________________________________________________ _____________________________
I guess that I used the wrong method in JNIEnv to call Java method?