2013-01-15 54 views
1

我創建了一個JNLP來加載applet和一些本機DLL文件。以下是各部件UnsatisfiedLinkError + JNLP + Applet + DLL

JNLP

<?xml version="1.0" encoding="UTF-8"?> 
<!-- href attribute contains relative path; 
    codebase attribute not specified --> 
<jnlp href="myKad.jnlp"> 
    <information> 
     <title>MyKad Reader Applet</title> 
     <vendor>MyKad</vendor> 
    </information> 
    <security> 
     <all-permissions/> 
    </security> 
    <resources> 
     <!-- Application Resources --> 
     <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se" /> 
     <jar href="HLB_Mykad-0.0.1-SNAPSHOT.jar" main="true"/> 
     <nativelib href="HLB_Mykad-0.0.1-SNAPSHOT.jar" download="eager"/> 
    </resources> 
    <applet-desc 
      name="MyKad Applet" 
      main-class="com.glexim.applet.GleximApplet" 
      width="1" 
      height="1"> 
    </applet-desc> 
    <update check="background"/> 
</jnlp> 

JAR(HLB_Mykad-0.0.1-SNAPSHOT.jar)結構的代碼(JAR的在頂部lavel包裝)

com.glexim.applet.GleximApplet 
META-INF 
Sample.dll 

HTML代碼

<applet jnlp_href="./applet/myKad.jnlp" 
code="com.glexim.applet.GleximApplet" id="gleximApplet" 
mayscript="true" width="0px" style="" /> 

加載小程序時,我收到以下在小程序中的異常con獨家:

java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: no Sample in java.library.path 
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) 
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) 
at java.lang.Thread.run(Unknown Source) 
Caused by: java.lang.UnsatisfiedLinkError: no Sample in java.library.path 
at java.lang.ClassLoader.loadLibrary(Unknown Source) 
at java.lang.Runtime.loadLibrary0(Unknown Source) 
at java.lang.System.loadLibrary(Unknown Source) 
at com.glexim.zf1.MyKad$1.run(MyKad.java:19) 
at java.security.AccessController.doPrivileged(Native Method) 
at com.glexim.zf1.MyKad.<clinit>(MyKad.java:13) 
at com.glexim.applet.GleximApplet.<init>(GleximApplet.java:43) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
at java.lang.reflect.Constructor.newInstance(Unknown Source) 
at java.lang.Class.newInstance0(Unknown Source) 
at java.lang.Class.newInstance(Unknown Source) 
at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source) 
at java.awt.event.InvocationEvent.dispatch(Unknown Source) 
at java.awt.EventQueue.dispatchEventImpl(Unknown Source) 
at java.awt.EventQueue.access$400(Unknown Source) 
at java.awt.EventQueue$2.run(Unknown Source) 
at java.awt.EventQueue$2.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) 
at java.awt.EventQueue.dispatchEvent(Unknown Source) 
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
at java.awt.EventDispatchThread.run(Unknown Source) 
Exception: java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: no Sample in java.library.path 

我的小程序簽名的小和小程序裏面所有的DLL文件也與同一簽名。

+0

你應該嘗試把你的nativelibs放在其他一些jar文件中(與主文件夾分開)。 –

+0

嗨吉爾伯託,謝謝你的迴應。我也試過,但沒有奏效。 – BTJ

回答

1

在JNLP文件中創建其他部分描述本地資源:

<resources os="Windows" arch="x86"> 
    <nativelib href="jar-with-nativelibs.jar"/> 
</resources> 

(您不必使用每個操作系統和架構支持的一個罐子,但建議)

而且之後,定義java.library.path屬性:

<property key="java.library.path" value="." /> 

而且你很好去。