title: java.lang.UnsatisfiedLinkError - JNI
body: <p>I keep getting a <em>java.lang.UnsatisfiedLinkError</em> error every time I  run my program. I have a native, a wrapper, and the program to call the native through the wrapper.</p>
  
  <p><strong>main.h</strong></p>
  
  <pre><code>#ifndef __MAIN_H__
  #define __MAIN_H__
  
  #include &lt;windows.h&gt;
  #ifdef BUILD_DLL
      #define DLL_EXPORT __declspec(dllexport)
  #else
      #define DLL_EXPORT __declspec(dllimport)
  #endif
  
  #include&lt;jni.h&gt;
  #include&lt;iostream&gt;
  
  using namespace std;
  
  extern "C"
  {
  
  JNIEXPORT void JNICALL native_MessageBox(string text, string title);
  
  }
  
  #endif
  </code></pre>
  
  <p><strong>main.cpp</strong></p>
  
  <pre><code>#include "main.h"
  
  #include&lt;windows.h&gt;
  #include&lt;iostream&gt;
  
  using namespace std;
  
  JNIEXPORT void JNICALL MsgBox(string text, string title)
  {
      MessageBox(NULL, text.c_str(), title.c_str(), MB_OK);
  }
  
  extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
  LPVOID lpvReserved)
  {
      switch (fdwReason)
      {
          case DLL_PROCESS_ATTACH:
              break;
  
          case DLL_PROCESS_DETACH:
              break;
  
          case DLL_THREAD_ATTACH:
              break;
  
          case DLL_THREAD_DETACH:
              break;
      }
      return TRUE;
  }
  </code></pre>
  
  <p><strong>Wrapper.java</strong></p>
  
  <pre><code>public class Wrapper
  {
     private static File nativeFile = null;
  
         static
     {
              //ArchitectureReader and OSReader are classes I made to read the CPU              
              //bits and the OS
      ArchitectureType archType = ArchitectureReader.getArcitecture();
      OSType osType = OSReader.getOS();
  
      String filename = "C:/native-";
  
      if (osType == OSType.Windows)
      {
          if (archType == ArchitectureType.BITS_32)
              filename += "win32";
          else if (archType == ArchitectureType.BITS_64)
              filename += "win64";
          else
              System.exit(1);
      }
      else
          System.exit(1);
  
      nativeFile = new File(filename + ".dll");
      if (!nativeFile.exists())
          System.exit(1);
  
      System.load(filename); //This is where the Exception is thrown
  }
  
  private static native void native_MessageBox(String text, String title);
  public static void MesageBox(String text, String title)
  {
      native_MessageBox(text, title);
  }
  
  public static String getNativePath()
  {
      return nativeFile.getAbsolutePath();
  }
  }
  </code></pre>
  
  <p><strong>Main.Java</strong></p>
  
  <pre><code>public class Main
  {
  public static void main(String[] args)
  {
      Wrapper.MessageBox("Testing JNI", "JNI");
  }
  }
  </code></pre>
  
  <p>The native was built using MinGW 64 bit. Anyway, I don't get why I get the error. Help?????</p>