aspose file tools*
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
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: 19723
    
  20

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: 19723
    
  20

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.
 
 
subject: How to create NewObject in JNI for different methods?