This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes How to create NewObject in JNI for different methods? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to create NewObject in JNI for different methods?" Watch "How to create NewObject in JNI for different methods?" New topic
Author

How to create NewObject in JNI for different methods?

Vinney Shanmugam
Ranch Hand

Joined: Aug 27, 2008
Posts: 104
I have done it with constructors, where i use to populate the values and add those values to the new object created. This can be retirved on the java side.

Say, if i have empty constructor and have setter methods(say, 4 methods), whose value will be filled in the native side and i have to create a object out of all these setter methods(say, 4 methods).

code below is for constructor.... how to create object using four different methods................

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19674
    
  18

The constructor is the same, except the signature is different and there are less parameters to the NewObject call.

The setter methods all need to be retrieved afterwards using GetMethodID and CallVoidMethod.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Vinney Shanmugam
Ranch Hand

Joined: Aug 27, 2008
Posts: 104
Can you give me a sample code of it please.... because, as of now i am populating the values in constructor and also NewObject is taking constrcutor as a parameter, which we are finding using GetMethodID. In case we have two setter methods, they ll ve different jmehtodID. How can i pass these two in NewObject? I am confused only at this point... Please clear me the air....

Thanks a lot for the reply.........
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19674
    
  18

I'm ignoring any possible errors here for simplicity:
Vinney Shanmugam
Ranch Hand

Joined: Aug 27, 2008
Posts: 104
Thanks a ton Rob.

It not only helped me to solve my problem but also to understand how to do it. I wont forget this in my lifetime.

A BIG THANKS.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to create NewObject in JNI for different methods?