I'm trying to use my C++ in a Java application but fail at the simple JNA stuff and i dont know why. For testing purposes I use the DLL from the following tutorial: http://msdn.microsoft.com/en-us/library/vstudio/ms235636.aspx
Now i try to load the Add method with JNA
import com.sun.jna.Native;
import com.sun.jna.Library;
public class Jnatest {
public interface CppLib extends Library {
CppLib INSTANCE = (CppLib)Native.loadLibrary("MathFuncsDll", CppLib.class);
double Add(double a, double b);
double Subtract(double a ,double b);
double Multiply(double a, double b);
double Divide(double a, double b);
}
public static void main(String[] args) {
System.setProperty("jna.library.path", "C:\\JNA\\");
CppLib lib = CppLib.INSTANCE;
double res;
res=lib.Add(1.0, 1.25);
System.out.println("add:\t"+res);
}
}
When Compiling i get the following Loading Exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: %1 ist keine zulässige Win32-Anwendung.
at com.sun.jna.Native.open(Native Method)
at com.sun.jna.Native.open(Native.java:1759)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:260)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
at com.sun.jna.Library$Handler.<init>(Library.java:147)
at com.sun.jna.Native.loadLibrary(Native.java:412)
at com.sun.jna.Native.loadLibrary(Native.java:391)
at Jnatest$CppLib.<clinit>(Jnatest.java:9)
at Jnatest.main(Jnatest.java:23)
First i thougt there is something wrong with the Library Path where the Files are located. But System.setProperty("jna.library.path", "C:\JNA\"); should set the path imo. What else could be wrong?
Thank You
David