Hi all,
sorry to bother you, I really have no idea how to do JNA and Applet. I'm hardly mazy, man.
Every time it will throw an error to me :
Exception in thread "thread applet-JNAApplet-1" java.lang.UnsatisfiedLinkError: Library 'jnidispatch' was not found by class loader sun.plugin2.applet.JNLP2ClassLoader@291aff
at com.sun.jna.Native.getWebStartLibraryPath(Native.java:858)
at com.sun.jna.NativeLibrary.<clinit>(NativeLibrary.java:576)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:372)
at com.sun.jna.Native.loadLibrary(Native.java:357)
at JNAApplet.init(JNAApplet.java:15)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
My program is so easy, I just want use Applet to revoke JNA and use the JNA to load a native lib.
here is the structure of my program:
Applet code :
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JPanel;
import com.sun.jna.Native;
public class JNAApplet extends JApplet {
public static Kernel32 kernel32 = null;
@Override
public void init() {
createGUI();
kernel32 = (Kernel32)Native.loadLibrary("Kernel32", Kernel32.class);
if (kernel32 == null) {
System.out.println("load kernel32 fail!");
} else {
System.out.println("load kernel32 success!");
}
}
private void createGUI() {
JPanel panelCenter = new JPanel();
JButton butTest = new JButton("Test");
panelCenter.add(butTest);
setContentPane(panelCenter);
}
}
When I run it on debug mode, it is ok! but when I deploy it , it will throw above error message to me.
My Applet html:
<html>
<head>
<title>JNA Applet</title>
</head>
<body>
<script src="deployJava.js"></script>
<script>
var attributes = { code:'JNAApplet', width:300, height:300} ;
var parameters = {jnlp_href: 'JNAApplet.jnlp'} ;
deployJava.runApplet(attributes, parameters, '1.5');
</script>
</body>
</html>
File 'JNAApplet.jnlp':
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="" href="">
<information>
<title>JNA Applet</title>
<vendor>Steven</vendor>
</information>
<resources>
<j2se version="1.5+"
href="http://java.sun.com/products/autodl/j2se" />
<jar href="JNAApplet.jar" main="true" />
</resources>
<applet-desc
name="JNA Applet"
main-class="JNAApplet"
width="300"
height="300">
</applet-desc>
<update check="background"/>
</jnlp>
I really have no idea. and I can't search any usefull infomation from Google and officer site.
Can any one help me? Thank you very much!!!!