title: Using Windows API call in Java using "native"
body: <p>I've tried to solve this issue by referring possible duplicates but none of them seem to be helpful.</p>
  
  <p>Here's a code that I'm using to call Win API methods in Java to get current Windows User Name, and a native Windows MessageBox, but I'm getting <code>UnsatisfiedLinkError</code> that says that my code is unable to locate the <code>native</code> method I'm trying to call.</p>
  
  <pre><code>public class TestNative
  {
      public static void main(String[] args)
      {
          long[] buffer= { 128 };
          StringBuffer username = new StringBuffer((int)buffer[0]);
          GetUserNameA(username,buffer);
          System.out.println("Current User : "+username);
          MessageBoxA(0,"UserName : "+username,"Box from Java",0);
      }
      /** @dll.import("ADVAPI32") */
      static native void GetUserNameA(StringBuffer username,long[] buffer);
      /** @dll.import("USER32") */
      private static native int MessageBoxA(int h,String txt,String title,int style);
  }
  </code></pre>
  
  <p>What can be my possible (relatively simple) solution to call native Windows methods in Java. I realize that it will kill the very reason of Java being a cross-platform language, but I need to work on a project for Windows, to be developed in Java.</p>
  
  <p>Thanks.</p>
  
  <p><strong>Update</strong></p>
  
  <p>As David Heffernan suggested, I've tried changing the method signature of <code>MessageBox</code> to <code>MessageBoxA</code>, but still it's not working.</p>