C
Colby Nyce
Hi all,
I am trying to call Java methods from C++ code using the JNI wrapper
functions that we have available in the "jmi" library, but I am having
difficulty figuring out how to obtain one of the required input variables.
I need to use any one of the "mljCall<type>Method" functions, such as:
mljCallVoidMethod
mljCallIntMethod
mljCallBooleanMethod
etc
These functions accept at least two parameters. The first is a "jobject",
and the second is a "jmethodID" (any additional arguments are treated as
input parameters to your Java method). I have been able to get an address
to my Java method, but I am not sure how to get an appropriate "jobject" to
use with this function. The code I have boils down to this:
/**************************************************************************/
jclass objectClass = mljFindClass("WebScopeInterfaceToJava");
jmethodID webscopeMethod = mljGetMethod(objectClass, "voidMethod",
"()V");
jobject j_obj = // How do I get this?
mljCallVoidMethod(j_obj,webscopeMethod);
/**************************************************************************/
Where do I get the correct "jobject" from? Is this available from the
global JVM or something? I have looked through a lot of the source code,
but I am finding it to be somewhat cryptic. Please bear with me, I am
completely new to JNI!
Thanks,
Colby
x7888
I am trying to call Java methods from C++ code using the JNI wrapper
functions that we have available in the "jmi" library, but I am having
difficulty figuring out how to obtain one of the required input variables.
I need to use any one of the "mljCall<type>Method" functions, such as:
mljCallVoidMethod
mljCallIntMethod
mljCallBooleanMethod
etc
These functions accept at least two parameters. The first is a "jobject",
and the second is a "jmethodID" (any additional arguments are treated as
input parameters to your Java method). I have been able to get an address
to my Java method, but I am not sure how to get an appropriate "jobject" to
use with this function. The code I have boils down to this:
/**************************************************************************/
jclass objectClass = mljFindClass("WebScopeInterfaceToJava");
jmethodID webscopeMethod = mljGetMethod(objectClass, "voidMethod",
"()V");
jobject j_obj = // How do I get this?
mljCallVoidMethod(j_obj,webscopeMethod);
/**************************************************************************/
Where do I get the correct "jobject" from? Is this available from the
global JVM or something? I have looked through a lot of the source code,
but I am finding it to be somewhat cryptic. Please bear with me, I am
completely new to JNI!
Thanks,
Colby
x7888