File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Calling a DLL from Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Calling a DLL from Java" Watch "Calling a DLL from Java" New topic

Calling a DLL from Java

Humberto Hernandez

Joined: Nov 01, 2000
Posts: 13
We want to call DLL methods from Java the same way they are called from a Visual Basic programm.
From what we have researched we have to do the following:
- Use JNI to call a C/C++ program. (Done)
- From the C++ program call the DLL. (Mmmh!)
In the second point we can call a regular function in the DLL compiled from a C program. But we don`t know how to call the method of an object for a purchased DLL. As a matter a fact we don't even know if it was generated from C,C++ or Visual Basic.
I know this question is more related to the usage DLLs but I don`t want to be seen asking questions in a Microsoft forum.:-)
We will appreciate if anyone can point us to an example.
Humberto Hernandez

Joined: Nov 01, 2000
Posts: 13
Looking closer at the litearature, it seems that what we really want to do is to call a COM object from Java.
Can I do it from Java or do I have to use C++.
Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
Com DLL's present a full set of other problems. The biggest is that they return MS specific Objects and not just c data types. Another is that they aren't stand alone and need a host application to run. You can create a c or c++ (or VB for that matter) wrapper to execute and convert the MS Objects to C or Java types.
If your company doesn't want to go through the time and expense, Linar Ltd. out of Engalnd has a pure java product called Jintegra which can access a comm dll using dllhost.exe as the executable. For more information check out their site here
Hope this helps

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Neetu Gupta

Joined: Nov 07, 2000
Posts: 4
You Must be having lib files also along with the DLL. If you have that, then put your dll in the system32 directory and link the lib files in your c++ project. It should work fine if the dll supports c++ calls
I agree. Here's the link:
subject: Calling a DLL from Java
It's not a secret anymore!