AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Calling a C++ dll from Java

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> comp.lang.java.tech
View previous topic :: View next topic  
Author Message
Samagna
Guest





PostPosted: Tue Sep 07, 2004 10:32 am    Post subject: Calling a C++ dll from Java Reply with quote



I need to call a function that is there in a C++ dll. The arguments to
the function are STRUCT and string. The return type is void. Also I
donot have any rights to change the dll and I have to use as it is....
So here goes my questions: 1. How to pass a struct variable from Java
to a function in DLL. 2. The function returns void and the second
argument is the output variable which I need to use. So is there
anyway, that call by reference can be used from Java? 3. Where should
I place my dll to compile it?

Quick reply would be appreicated.
Thanks in advance.
Samagna
Back to top
Chris Uppal
Guest





PostPosted: Tue Sep 07, 2004 11:55 am    Post subject: Re: Calling a C++ dll from Java Reply with quote



Samagna wrote:

Quote:
I need to call a function that is there in a C++ dll. The arguments to
the function are STRUCT and string.

You can't, I'm afraid. Java does not have the ability to call arbitrary code
from an arbitrary DLL, nor does it understand 'structs'.

So you have to be a bit more indirect. What you will have to do is write your
own C or C++ code which follows the JNI conventions, and which therefore /can/
be called from Java, and then call the other DLL from that.

The Sun JNI tutorial at:

http://java.sun.com/docs/books/tutorial/native1.1/index.html

should get you started on JNI programming. It's not difficult if you keep it
simple, and it doesn't sound as if you need to do anything very complicated for
these purposes.

-- chris




Back to top
Robert kebernet Cooper
Guest





PostPosted: Sun Dec 19, 2004 11:35 pm    Post subject: Re: Calling a C++ dll from Java Reply with quote



Depending on what you are trying to do, the IBM Java-COM bridge can be
a MUCH MUCH easier way of moving data between the two than hand
building JNI stuff. I have used this with Microsoft MapPoint and some
other MS-ish API's quite successfully.
http://www-106.ibm.com/developerworks/library/j-intbridge/

Back to top
Tilman Bohn
Guest





PostPosted: Mon Dec 20, 2004 11:48 pm    Post subject: Re: Calling a C++ dll from Java Reply with quote

[f'up2 cljp]

In message <1103499319.457151.242540 (AT) f14g2000cwb (DOT) googlegroups.com>,
Robert kebernet Cooper wrote on 19 Dec 2004 15:35:19 -0800:

[...]
Quote:
http://www-106.ibm.com/developerworks/library/j-intbridge/

This looks very interesting, I hadn't known about that! Could come in
very handy indeed in an upcoming project, so thanks from me for that
pointer!

--
Cheers, Tilman

`Boy, life takes a long time to live...' -- Steven Wright

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> comp.lang.java.tech All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.