Need help assigning instance of java class to a jobject

Discussion in 'Java' started by MP, Nov 7, 2004.

  1. MP

    MP Guest

    I have the Invocation API code working properly. I get a jclass with the
    proper path to our jar successfully. I would now like to create an
    instance of this class so I can call some non static instance methods on
    it. I can successfully get its constructor (I think that's what I'm
    getting) by using mid = env->GetMethodID(cls, "<init>", "()V);. However,
    when I try to get create an instance jobject theclass =
    env->NewObject(cls, mid) I get a NULL returned. Any ideas?
     
    MP, Nov 7, 2004
    #1
    1. Advertising

  2. MP

    Oscar kind Guest

    MP <> wrote:
    > I have the Invocation API code working properly. I get a jclass with the
    > proper path to our jar successfully. I would now like to create an
    > instance of this class so I can call some non static instance methods on
    > it. I can successfully get its constructor (I think that's what I'm
    > getting) by using mid = env->GetMethodID(cls, "<init>", "()V);. However,
    > when I try to get create an instance jobject theclass =
    > env->NewObject(cls, mid) I get a NULL returned. Any ideas?


    Yes: this is not Java.
    Hint: the "->" operator doesn't exist. That's C/C++.


    --
    Oscar Kind http://home.hccnet.nl/okind/
    Software Developer for contact information, see website

    PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
     
    Oscar kind, Nov 7, 2004
    #2
    1. Advertising

  3. Oscar kind <> writes:

    > Yes: this is not Java.
    > Hint: the "->" operator doesn't exist. That's C/C++.


    Yes, Java's JNI (which he uses) uses C/C++ underneath. But JNI is
    definitely associated with Java.
     
    Tor Iver Wilhelmsen, Nov 7, 2004
    #3
  4. MP

    Oscar kind Guest

    Tor Iver Wilhelmsen <> wrote:
    > Oscar kind <> writes:
    >
    >> Yes: this is not Java.
    >> Hint: the "->" operator doesn't exist. That's C/C++.

    >
    > Yes, Java's JNI (which he uses) uses C/C++ underneath. But JNI is
    > definitely associated with Java.


    Associated with: yes. You are right about that.

    But as then it's about interfacing Java with another programmig language,
    I'd expect the OP saying so. As with all cases where two or more
    programming languages are mixed.


    --
    Oscar Kind http://home.hccnet.nl/okind/
    Software Developer for contact information, see website

    PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
     
    Oscar kind, Nov 7, 2004
    #4
  5. MP

    MP Guest

    MP wrote:
    > I have the Invocation API code working properly. I get a jclass with the
    > proper path to our jar successfully. I would now like to create an
    > instance of this class so I can call some non static instance methods on
    > it. I can successfully get its constructor (I think that's what I'm
    > getting) by using mid = env->GetMethodID(cls, "<init>", "()V);. However,
    > when I try to get create an instance jobject theclass =
    > env->NewObject(cls, mid) I get a NULL returned. Any ideas?


    Yes, as some readers have noticed, I should have indicated that the OP
    is related to JNI. I'm hoping someone here has some experience with the
    problem I am experiencing...
     
    MP, Nov 7, 2004
    #5
    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. Replies:
    10
    Views:
    7,067
  2. Vijayk
    Replies:
    12
    Views:
    7,950
    Chris Uppal
    Oct 25, 2005
  3. Tim  Wong

    C++ JNI jobject conversion

    Tim Wong, Dec 22, 2004, in forum: C++
    Replies:
    4
    Views:
    7,347
    Tim Wong
    Jan 4, 2005
  4. groupie

    jObject stays blank

    groupie, May 14, 2008, in forum: Java
    Replies:
    1
    Views:
    354
    Roedy Green
    May 15, 2008
  5. Philipp Kraus

    JNI generic type of jobject

    Philipp Kraus, Oct 4, 2011, in forum: Java
    Replies:
    6
    Views:
    911
    Daniel Pitts
    Oct 4, 2011
Loading...

Share This Page