Trouble with JNI wrapper functions

Discussion in 'Java' started by Colby Nyce, Sep 8, 2011.

  1. Colby Nyce

    Colby Nyce Guest

    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
    Colby Nyce, Sep 8, 2011
    #1
    1. Advertising

  2. Colby Nyce

    Roedy Green Guest

    On Thu, 8 Sep 2011 15:10:06 -0400, "Colby Nyce" <>
    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)
    Roedy Green, Sep 8, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Hunsley

    IBM's JNI fails where Sun's JNI works

    Alex Hunsley, Nov 3, 2003, in forum: Java
    Replies:
    4
    Views:
    827
    Alex Hunsley
    Nov 4, 2003
  2. Rob
    Replies:
    2
    Views:
    1,396
  3. Jim

    JNI wrapper class

    Jim, Sep 11, 2005, in forum: Java
    Replies:
    2
    Views:
    2,151
    Stefan Schulz
    Sep 12, 2005
  4. Replies:
    2
    Views:
    4,354
    Derek
    Jan 14, 2005
  5. Philipp Kraus

    JNI C++ Wrapper

    Philipp Kraus, Sep 30, 2011, in forum: Java
    Replies:
    1
    Views:
    1,485
    Roedy Green
    Oct 10, 2011
Loading...

Share This Page