Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Trouble with JNI wrapper functions

Reply
Thread Tools

Trouble with JNI wrapper functions

 
 
Colby Nyce
Guest
Posts: n/a
 
      09-08-2011
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




 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      09-08-2011
On Thu, 8 Sep 2011 15:10:06 -0400, "Colby Nyce" <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

> Please bear with me, I am
>completely new to JNI!


See http://mindprod.com/jgloss/jni.html

Order a textbook.

Google the names of problematic methods. Looking at other people's
code will give you clues on how to use them.
--
Roedy Green Canadian Mind Products
http://mindprod.com
The modern conservative is engaged in one of man's oldest exercises in moral philosophy; that is,
the search for a superior moral justification for selfishness.
~ John Kenneth Galbraith (born: 1908-10-15 died: 2006-04-29 at age: 97)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JNI C++ Wrapper Philipp Kraus Java 1 10-10-2011 09:54 PM
WebSphere JVM Access Violation Problem running Java program that calls methods in a Windows C++ DLL via a JNI wrapper....... adgarcia13 Java 2 06-28-2006 11:19 AM
JNI wrapper class Jim Java 2 09-12-2005 09:37 AM
including package name in jni wrapper Rob Java 2 06-14-2004 03:55 PM
IBM's JNI fails where Sun's JNI works Alex Hunsley Java 4 11-04-2003 10:34 AM



Advertisments