抛出java.lang.ClassNotFoundException

时间:2010-02-02 12:13:49

标签: java jar executable-jar

I have embedded an applet (jar file)in a html page 

现在,当我尝试访问该网页时,它会出现以下错误。

<APPLET CODE="com.xxx.tru.ReadNFCSerialNumber" NAME="Read" ID="Read" MAYSCRIPT alt="Photo Id"   ARCHIVE="\test.jar, \ojdbc14.signed.jar, \ojdbc14_g.signed.jar" WIDTH="100%"  HEIGHT="100%"  HSPACE="1"  VSPACE="1">
</APPLET>




load: class com.xxx.tru.ReadNFCSerialNumber not found.
java.lang.ClassNotFoundException: com.xxx.tru.ReadNFCSerialNumber
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.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://localhost/popit/POPit/com/xxx/tru/ReadNFCSerialNumber.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)
... 7 more
Exception: java.lang.ClassNotFoundException: com.xxx.tru.ReadNFCSerialNumber

我做错了什么?

2 个答案:

答案 0 :(得分:1)

Web浏览器正在尝试从URI http://localhost/popit/POPit/com/xxx/tru/ReadNFCSerialNumber.class而不是jar文件加载您的类。 ARCHIVE属性的内容对我来说很可疑。它真的应该是逗号和空格分隔列表吗?此外,文件名前面的反斜杠看起来很可疑:

ARCHIVE="\test.jar, \ojdbc14.signed.jar, \ojdbc14_g.signed.jar"

我建议您考虑修复ARCHIVE属性,然后查看Web浏览器是否会根据您的需要从jar中加载类文件。

答案 1 :(得分:0)

缺少CODEBASE属性。只是一个想法。code base