*
The moose likes Other JSE/JEE APIs and the fly likes DLL FIle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "DLL FIle " Watch "DLL FIle " New topic
Author

DLL FIle

Jignesh Lakhani
Greenhorn

Joined: Jan 10, 2006
Posts: 2
Hi

How to use 3rd party DLL file in Java.

Thanks
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

The API you need to call native code in a DLL is JNI (Java Native Interface).

JNI requires that the functions in the DLL adhere to a specific calling convention (i.e., the names and parameters of the functions have some restrictions).

If you have a third party DLL that does not conform to those restrictions, then you write a bridge DLL yourself, with functions that can be called through JNI, and the functions in the bridge DLL call the functions in the third party DLL.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Jignesh Lakhani
Greenhorn

Joined: Jan 10, 2006
Posts: 2
I have DLL file which can't be edit.
I have Java Access Bridge but how to use it for 3rd party dll file.
So what should I do.
Can you give any sample.

Thanks
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Moving to Other APIs


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Originally posted by Jignesh Lakhani:
I have DLL file which can't be edit.
I have Java Access Bridge but how to use it for 3rd party dll file.
So what should I do.
Can you give any sample.

Thanks


Did you understand my first response? You don't need to edit a DLL file. Do this:

Write your own bridge DLL in C or C++. That DLL should contain functions in such a format that they can be called through JNI, the Java Native Interface. The only thing the functions in your own DLL have to do is call the functions in the existing 3rd party DLL that you have (converting parameters and return values as appropriate).

From your Java program, call the functions in your own bridge DLL via JNI.

Do you mean Java Access Bridge? That's not an API meant to call any arbitrary 3rd party DLL with.

If you don't know how JNI works, look at these, or search for more info using Google:
Java Native Interface
Enhance your Java application with Java Native Interface
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41114
    
  45
There are a few open source projects that purport to make it easier to connect Java with COM or DLL objects, including Jacob and Jawin.


Ping & DNS - my free Android networking tools app
 
Consider Paul's rocket mass heater.
 
subject: DLL FIle
 
Similar Threads
jni methos in c++ class
sycmjit.dll
a VB Question
what is dll?
dll in java