Create a java.util.Map in JNI

G

gautam.chavan

hello all,

Can anyone tell me how to create & use Java Maps in my C++
code...
I've used java.util.Vector, it works fine.
I work on a Sun Fire V440 machine.

regards,
gautam.
 
A

AndrewTK

C doesn't use Java. Java may use C but I dont know how to do that.

You'd be best off describing what a Map is to the C community and
taking it from there...
 
C

Chris Uppal

Can anyone tell me how to create & use Java Maps in my C++
code...
I've used java.util.Vector, it works fine.

java.util.Map is an interface, not a class. You can create instances of
classes that implement that interface (such as java.util.HashMap and
java.util.TreeMap). It's just the same in C++/JNI as it is in Java (just more
verbose).

-- chris
 
J

john m

use the JNI methods provided in C++ to create an object that implements
the Map interface. remember the map interface is just a interface...not
a concrete class.

don't forget c++ has its own containers like this, vector and map etc
etc...do you really need to do this?..just #include <list> and or
#include <map> and you're sorted..excuse the pun
 
R

Roedy Green

Can anyone tell me how to create & use Java Maps in my C++
code...
I've used java.util.Vector, it works fine.
I work on a Sun Fire V440 machine.

If you have done vector you need exactly the same sort of thinking to
do ArrayList or HashMap. Perhaps the only extra piece you need it how
to create a reference to an Interface rather than a Class so you can
do Map x in C++.

It looks as if you treat interfaces as if they were full classes. See
page 48 of the Sheng Liang book. See
http://mindprod.com/jgloss/jni.html
 
G

gautam.chavan

hello all,

Thanks a lot.
It worked.
I had given a wrong signature to the "put" method of HashMap.

Warm Regards,
gautam.
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top