gpt4 book ai didi

java - UnsatisfiedLinkError + JNLP + Applet + DLL

转载 作者:太空宇宙 更新时间:2023-11-04 07:51:43 25 4
gpt4 key购买 nike

我创建了一个 JNLP 来加载小程序和一些 native 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 打包在顶部)

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="" />

加载小程序时,我在小程序控制台中遇到以下异常:

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

我的Applet是经过签名的Applet,并且Applet内的所有DLL文件也都使用相同的签名进行签名。

最佳答案

在 JNLP 文件中创建描述 native 资源的其他部分:

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

(您不必为每个支持的操作系统和架构使用一个 jar,但建议这样做)

然后,定义 java.library.path 属性:

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

你就可以开始了。

关于java - UnsatisfiedLinkError + JNLP + Applet + DLL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14347743/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com