title: Java applet, problem loading native dll
body: <p>I am writing a Java applet which loads dll's created in unmanaged C++. I am writing some basic test to get it loading.</p>
  
  <p>Here's the code:</p>
  
  <p>The DLL:</p>
  
  <pre><code>#define DllExport _declspec(dllexport)
  DllExport int calc();
  
  
  DllExport int calc() {
  return 1000;
  }
  </code></pre>
  
  <p>The applet:</p>
  
  <pre><code>import java.applet.*;
  import java.awt.*;
  
  
  public class app extends Applet {
  
     int width, height;
     private native int calc();
  
     public void init() {
     try {
         System.loadLibrary("appletdll.dll");
         setBackground( Color.black );
     }
     catch(Exception e) {
         setBackground( Color.red );
                 // for debugging, is there another way to for example print 
                 // exception messages in an applet?
     }
  
     //width = getSize().width;
     width = calc();
     height = getSize().height;
    }
  
    public void paint( Graphics g ) {
       g.setColor( Color.green );
       for ( int i = 0; i &lt; 10; ++i ) {
           g.drawLine( width, height, i * width / 10, 0 );
       }
    }
  }
  </code></pre>
  
  <p>The HTML running the applet:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;&lt;title&gt;simple page&lt;/title&gt;&lt;/head&gt;
  &lt;body&gt;
  
  &lt;applet width=400 height=400 code="app.class" archive="apptest.jar"&gt; &lt;/applet&gt; 
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>All I am getting when running in Firefox is a black 400x400 background.
  When running in applerviewer, I get an UnsatisfiedLinkError on calc(). </p>
  
  <p>The .jar is signed using this guide:
  <a href="http://wiki.plexinfo.net/index.php?title=How_to_sign_JAR_files" rel="nofollow">http://wiki.plexinfo.net/index.php?title=How_to_sign_JAR_files</a></p>
  
  <p>In the folder I have:
  app.class,
  apptest.jar,
  appletdll.dll,
  applet.htm,<br>
  myKeystore</p>
  
  <p>I am probably doing alot wrong, I am just trying to get some basics working. I've been looking at applet+dll guides but they are mostly outdated. 
  If there is anything that is not clear, just ask.</p>
  
  <p>Thanks</p>