title: JNA UnsatisfiedLinkError %1 not a valid Win32 application while trying to load C++ DLL
body: <p>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:
  <a href="http://msdn.microsoft.com/en-us/library/vstudio/ms235636.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/vstudio/ms235636.aspx</a></p>
  
  <p>Now i try to load the Add method with JNA</p>
  
  <pre><code>   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); 
      }
  }
  </code></pre>
  
  <p>When Compiling i get the following Loading Exception:</p>
  
  <pre><code>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.&lt;init&gt;(Library.java:147)
      at com.sun.jna.Native.loadLibrary(Native.java:412)
      at com.sun.jna.Native.loadLibrary(Native.java:391)
      at Jnatest$CppLib.&lt;clinit&gt;(Jnatest.java:9)
      at Jnatest.main(Jnatest.java:23)
  </code></pre>
  
  <p>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?</p>
  
  <p>Thank You</p>
  
  <p>David</p>