• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

How do call the function from .dll file in java

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

I have added the .dll file which is required for my code in JACOB jar library native path. I dont know in which program the .dll file was written but i know the function name written in them. I have to call that function from java, Could you please help me how to call the function in .dll file from java program.
 
Saloon Keeper
Posts: 13997
315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kerthika, welcome to CodeRanch!

Do a Google search for JNA, or Java Native Access. There should be plenty of tutorials or articles explaining how to set it up and how to call native procedures from dynamic libraries.
 
kerthi Joe
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi stephan,

Thank you for your suggestion. I have used the native library jar in RAD and have given the .dll file path in the native library location in that jar.My program is ,

public class testFromDllFile {

private native int GetIMSData(String A,String B,String C,String D,int x,String E,int y,String F,int z,int a,String G,String H);

public static void main(String[] args) {
int x = new testFromDllFile().GetIMSData("A","B","C","D",0,"E",0,"",0,0,"","F");
System.out.println("x"+x);
}

static {
System.loadLibrary("TRNSACTN");
}
}


But when i run this program am getting "The java class could not be loaded. java.lang.UnsatisfiedLinkError: D:\DLL_file\TRNSACTN.DLL: Can't find dependent libraries" .
Am i missing anything here.?
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

kerthi Joe wrote:But when i run this program am getting "The java class could not be loaded. java.lang.UnsatisfiedLinkError: D:\DLL_file\TRNSACTN.DLL: Can't find dependent libraries" .
Am i missing anything here.?


Well I've never done it myself, but it appears to be telling you that the library contains links to other dependant libraries that it can't find - presumably because you haven't told it where to look for them.

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

Winston Gutkowski wrote:

kerthi Joe wrote:But when i run this program am getting "The java class could not be loaded. java.lang.UnsatisfiedLinkError: D:\DLL_file\TRNSACTN.DLL: Can't find dependent libraries" .
Am i missing anything here.?


Well I've never done it myself, but it appears to be telling you that the library contains links to other dependant libraries that it can't find - presumably because you haven't told it where to look for them.

Winston



I agree with Winston.

Your TRNSACTN.DLL file might also need other DLL's too. Looking at the command line and such, it looks like you're on Windows. I'm going to suggest an approach to this. If you already have a Microsoft development tool of some kind on that PC (ex: Microsoft Visual C++), look for the 'depends.exe' program on your PC; it's a dependency walker tool. If you have it, use it to find out what DLL dependencies your program/DLL file has.

I'm going to guess that the original program was made through an IDE of some kind (MS Visual C++, Visual Studio, C#, Intel FORTRAN, etc) and was compiled in a manner where it expected the other redistributable files (DLL's) would already be on whatever PC you wanted to install the program to.

CNH
 
Marshal
Posts: 75840
361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch [Only 1¾ years on!]
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic