Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DLL FIle

 
Jignesh Lakhani
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

How to use 3rd party DLL file in Java.

Thanks
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jignesh Lakhani
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Other APIs
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic