Need help assigning instance of java class to a jobject

M

MP

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?
 
O

Oscar kind

MP said:
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++.
 
T

Tor Iver Wilhelmsen

Oscar kind said:
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.
 
O

Oscar kind

Tor Iver Wilhelmsen said:
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.
 
M

MP

MP said:
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...
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top