我签了我的小程序,它在jar中。
我在jsp中添加了以下代码嵌入applet
<applet name="viewerApplet" id="TViewerApplet" width="100%" height="500" code="TViewerApplet.class" codebase="/WEB-INF/lib" mayscript="mayscript" archive="C:/Eclipse_Workspace/Velocity/BSLI_MIS_VELOCITY/WebContent/WEB-INF/lib/SSignedTAppletViewer.jar">
但我得到以下异常
java.net.MalformedURLException: unknown protocol: c
编辑: 现在我正在使用
<applet name="viewerApplet" id="TViewerApplet" width="100%" height="500" code="TViewerApplet.class" align="baseline" codebase="." mayscript="mayscript" archive="SSignedTAppletViewer.jar,cmbview81.jar">
新例外 load:未找到类TViewerApplet.class。
java.lang.ClassNotFoundException: TViewerApplet.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
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.io.IOException: open HTTP connection failed:http://10.160.118.171:8086/BSLI_MIS_VELOCITY/TViewerApplet/class.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 9 more
Exception: java.lang.ClassNotFoundException: TViewerApplet.class
答案 0 :(得分:2)
archive="C:/Eclipse_Workspace/Velocity/BSLI_MIS_VELOCITY/WebContent/WEB-INF/lib/SSignedTAppletViewer.jar"
这有两个问题。
file:
的URL - 因此unknown protocol: c
)。但是使用相对路径。/WEB-INF/lib/
通常是为服务器保留的,没有公共访问权限。你需要将Jar放在其他地方。我通常使用/lib/
。
- TViewerApplet位于SSignedTAppletViewer.jar
- 是的,它在com.mind包中
- 现在jar位于jsp所在的文件夹中
- 我已经检查过jar -tvf,类在jar中
醇>
好。将它们放在一起会产生这样的applet元素:
<applet
name="viewerApplet"
id="TViewerApplet"
width="100%"
height="500"
code="com.mind.TViewerApplet"
align="baseline"
codebase="."
mayscript="mayscript"
archive="SSignedTAppletViewer.jar,cmbview81.jar">
</applet>
唯一的变化是code
属性,从TViewerApplet.class
到com.mind.TViewerApplet
- .class
不是必需的,但包是。