Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

Create a java.util.Map in JNI

Thread view: 
gautam.chavan@gmail.com - 27 Mar 2006 13:54 GMT
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.
AndrewTK - 27 Mar 2006 14:24 GMT
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...
Chris Uppal - 27 Mar 2006 14:30 GMT
>          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
john m - 27 Mar 2006 15:19 GMT
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

> hello all,
>
[quoted text clipped - 5 lines]
> regards,
> gautam.
Roedy Green - 27 Mar 2006 20:07 GMT
>         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
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

gautam.chavan@gmail.com - 28 Mar 2006 05:54 GMT
hello all,

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

Warm Regards,
gautam.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.