JNI: Passing array of objects from C++ to Java

Discussion in 'Java' started by Alex, Nov 30, 2004.

  1. Alex

    Alex Guest

    From C++ to Java using JNI
    I need to pass an array of orbitrary number of objetcts
    that consists of a string and a float.


    All suggestions are really appriciated!
    Thnaks
    Alex, Nov 30, 2004
    #1
    1. Advertising

  2. On 29 Nov 2004 17:38:21 -0800, Alex wrote:
    > From C++ to Java using JNI
    > I need to pass an array of orbitrary number of objetcts
    > that consists of a string and a float.


    Please don't multipost. Followup set.

    Have you used JNI at all?

    What *specifically* are you having problems with?

    - Get the class descriptor with FindClass() or GetObjectClass().

    - Create an empty array of the appropriate size with NewObjectArray().

    - Use SetObjectArrayElement() to populate the array with instances of
    your class.

    - To call the Java method, look up the method in the class with
    GetMethodId() or GetStaticMethodId(), then call it using the
    appropriate CallXXXMethod() function. Pass your array as an
    argument.

    The JNI tutorial is here (the section on invocation is dated but the
    rest is still valid):

    http://java.sun.com/docs/books/tutorial/native1.1/index.html

    In particular, look at these sections (but look at the rest too):

    http://java.sun.com/docs/books/tutorial/native1.1/implementing/array.html
    http://java.sun.com/docs/books/tutorial/native1.1/implementing/method.html

    The complete JNI specification is here:

    http://java.sun.com/j2se/1.5.0/docs/guide/jni/index.html

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Gordon Beaton, Nov 30, 2004
    #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. Vikas
    Replies:
    2
    Views:
    14,450
    Vikas
    Aug 27, 2003
  2. Replies:
    3
    Views:
    7,371
    Gordon Beaton
    Dec 23, 2005
  3. Guest
    Replies:
    2
    Views:
    1,942
    Guest
    Jun 7, 2007
  4. Guest
    Replies:
    1
    Views:
    605
    Alan Johnson
    Jun 6, 2007
  5. bernd
    Replies:
    1
    Views:
    782
    bernd
    Jun 13, 2008
Loading...

Share This Page