Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

how to use DLL in java code

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

I am working on a project which needs to use an dll api originaly written to be used with visual basic or other microsoft platform languages like VC++ etc.

Is there any way to use a dll api in java , I heard that using JNI we can do this, but could not get the proper information to use JNI for invoking objects and their methods into java application which are embedded inside dll api.

Is there anybody who has ever done this before and can share his experience with me here.


Regs,
Rishi Tyagi
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JNI is the trick. Make a special DLL that is JNI callable and a Java class with just the methods that call straight through to the DLL. The DLL can call other C/C++ or whatever programs as needed.

Did you start here to learn JNI? http://java.sun.com/docs/books/tutorial/native1.1/
 
Rishi Tyagi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks James,

But as you mentioned that we need to make dll JNI compatible, what we need to do for that?

Actually the api i want to use is a third party api and i dont have source of it and hence it is next to impossible to make any change in that dll.
Is there any way so that we can invoke dll without touching it.

Regs,
Rishi
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll have to put your own custom DLL in front:

Java -> JNI -> Custom DLL -> standard DLL call -> 3rd Party DLL

We've done this for a couple desktop products.
 
Rishi Tyagi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks James,
Will try in this way. Lets hope if it helps us.
Regs,
Rishi Tyagi
 
I just had the craziest dream. This tiny ad was in it.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic