Using DLL file in Java Program
843829Mar 11 2003 — edited Mar 19 2003hi
my problem is
i dont want to create a dll file instead want to use a already existing dll file
i have a dll file and it has some functions in it.
i want to load that dll file into java class and use those functions.
for eg assume dll file has a method "add" which takes 2 integers and adds them returns the result.
dll method-
# int add(int x,int y) // i want to use this method in my java class
i wrote the following code
//java class
class test
{
native int add(int x, int y);
static
{
System.loadLibrary("dllfilename");
}
public static void main(String s[])
{
test t = new test();
int i = t.add(10,20);
System.out.println("result: "+i);
}
}
Dont think that if i want to add two numbers then why to go for dll,
There are many other complex functions in dll file and i want to use them.
i could not succeed with the above program. I saved dll and java file in same location. System.loadLibrary is loading my dll file but giving unsatisfied link error.
i am sure it is loading the file because if i remove the dll file from this folder it is giving no dll file in library path error,so it is loading dll file but not executing the function.
can any one help me.