• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

DLL FIle

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

How to use 3rd party DLL file in Java.

Thanks
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to Other APIs
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic