 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Samagna Guest
|
Posted: Tue Sep 07, 2004 10:32 am Post subject: Calling a C++ dll from Java |
|
|
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
|
Posted: Tue Sep 07, 2004 11:55 am Post subject: Re: Calling a C++ dll from Java |
|
|
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
|
Posted: Sun Dec 19, 2004 11:35 pm Post subject: Re: Calling a C++ dll from Java |
|
|
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
|
Posted: Mon Dec 20, 2004 11:48 pm Post subject: Re: Calling a C++ dll from Java |
|
|
[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:
[...]
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 |
|
 |
|
|
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
|
|