目标是从jar文件运行applet.
问题是applet似乎只想从爆炸的jar文件中运行.
Internet上的示例建议使用此applet标记:
<applet code="com.blabla.MainApplet"
archive="applet.jar"
width="600" height="600">
这甚至不会尝试查看jar文件并失败:
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8080/helloWord/com/blabbla/MainApplet.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
将代码库而不是archive属性设置为jar文件.看起来好一点.但是,JVM没有意识到它必须打开jar文件:
<applet code="com.blabla.MainApplet"
codebase="applet.jar"
width="600" height="600">
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8080/helloWord/applet.jar/com/blabbla/MainApplet.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
如何制定applet标记以从jar文件中启动applet类?
最佳答案 问题是Java控制台正在缓存以前的坏罐子.在Java控制台中清除缓存后,第一个版本的代码运行正常.
<applet code="com.blabla.MainApplet"
archive="applet.jar"
width="600" height="600">