File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do call the function from .dll file in java

 
kerthi Joe
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Stephan van Hulst
Bartender
Pie
Posts: 4840
34
Chrome Netbeans IDE Windows
  • 0
  • Mark post as helpful
  • send pies
  • 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: 2
  • 0
  • Mark post as helpful
  • send pies
  • 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.?
 
Winston Gutkowski
Bartender
Pie
Posts: 9484
50
Eclipse IDE Hibernate Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Charles Hargrave
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Campbell Ritchie
Sheriff
Pie
Posts: 47281
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch [Only 1¾ years on!]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic