Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

how to use DLL in java code  RSS feed

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • 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)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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
  • 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)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks James,
Will try in this way. Lets hope if it helps us.
Regs,
Rishi Tyagi
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!