• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to invoke a dll

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in java can i invoke a dll which is written for a vc++ program. this dll is used for encrypting and dcrypting now can i invoke this dll in java and try to use the method of it which decrypts. if yes then how to go bout it
 
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
to call the dll and load it on to memory u will need to use the JNI method system.loadLibrary();
here is an example code for the same
I hope it helps
Regds
Gautham Kasinath
 
Srinath R
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what i get from the example u have shown is that v need to have all the methods in the dll to be declared with the access modifier as native in our java program, and if the method accepts parameters v need to send the parameters from the navite method ?
kindly correct me if i am wrong.
tnx
srinath
 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Well yeah! u r on de rite track..
Is it someting else dat u r lookin for?? )
Regds
Gautham Kasinath
 
Srinath R
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
now in fact i am even more confused b'coz when i declare the method native how does my prg going to check if the method is present in the dll or not what happens if their is some type mismatch or some thing of that sought?
and can this dll be written even in vb? or can i invoke even a VB dll?
 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Well there are certain rules when adhering to JNI.. some of these force the programmers to use the same method name and arguments and return types as the Java Code defined has declared.
This leaves very less room for errors if any..
here is a sample code for the c program that I used

further I used a command line compilation to make the same a dll.
The HelloWorld.h is a javah generated header file. run javah on the class file created for the Java Source.
I hope this helps
Regds
Gautham Kasinath
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic