Using DLL functions in JAVA

107 views
Skip to first unread message

Gigi

unread,
Jun 25, 2013, 12:52:49 PM6/25/13
to jna-...@googlegroups.com
Hi I am neew to using JNA.
In all what i want to do is use the DLL file in java & call the functions from DLL file.
I created a simple multiplication DLL from c++ program & trying to use it.

import com.sun.jna.*;
public class MainMy {
public interface MyTest extends Library {
MyTest INSTANCE = (MyTest) Native.loadLibrary(
(Platform.isWindows() ? "MyTest" : "MyTest"), MyTest.class);
int getmultiplication(int a , int b);
}
public static void main(String[] args) {
System.out.println("START ..now going to load dll");
MyTest sdll = MyTest.INSTANCE;
System.out.println("loaded the class successfully.");
int a = 3;
int result1 = sdll.getmultiplication(a, 2); // calling function with int parameter&result
//System.out.println("giveIntGetInt("+a+"): " + result1);

}
}
When i run this java program i am getting following error-
START ..now going to load dll
loaded the class successfully.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'getmultiplication': The specified procedure could not be found.
at com.sun.jna.Function.<init>(Function.java:179)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:344)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:324)
at com.sun.jna.Library$Handler.invoke(Library.java:203)
at $Proxy0.getmultiplication(Unknown Source)
What i am missing???
Reply all
Reply to author
Forward
0 new messages