如何将小程序与 jar 中的包一起使用
我有一个小程序(Applet,不是 JApplet),它有很多组织成包的类,包括小程序本身。我到处寻找如何使用那个罐子作为小程序。它不可运行,并且具有如下所示的清单文件:
Manifest-Version: 1.0
Class-Path: AppletSource.jar
我将其放入 html (Game.html) 中,如下所示:
<applet code="Game/Game.class" archive="Game.jar" width=800 height=600>
Your browser needs JAVA!!!
</applet>
正如您所看到的,该类名为 Game.class,Package Game 和 jar Game.jar。 清单位于 Game.jar/META-INF
当我使用 appletviewer Game.html
时,我收到错误(java.security.AccessControlException:访问被拒绝),如果我打开 .html,我会收到ClassNotFoundException:Game.Game.class
。我能做些什么?
I have an applet (Applet, not JApplet) that has a lot of classes organized into packages, including the applet itself. I have looked everywhere for how to use that jar as an applet. It is not runnable and has a manifest file like such:
Manifest-Version: 1.0
Class-Path: AppletSource.jar
I put it in an html (Game.html), as such:
<applet code="Game/Game.class" archive="Game.jar" width=800 height=600>
Your browser needs JAVA!!!
</applet>
As you can see the class is called Game.class, Package Game and the jar Game.jar.
The manifest is in Game.jar/META-INF
When I use the appletviewer Game.html
I get an error (java.security.AccessControlException: access denied) and if I open the .html I get a ClassNotFoundException: Game.Game.class
. What can I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试
同时检查包名称是否确实是Game,而不是game。
try
Also check that the package name is really Game and not game.
applet 代码属性的格式来自 oracle 文档“The value appletFile can be of the form classname.class or of the form packagename.classname.class.”。
该文件与小程序的基本 URL 相关。不可能是绝对的。
还可以尝试将 jar 添加到与 html 相同的目录中。
有关更多信息,请参阅此文档
http://docs.oracle.com/javase/1.4 .2/docs/guide/misc/applet.html
The format for the applet code attribute is from oracle doc "The value appletFile can be of the form classname.class or of the form packagename.classname.class.".
This file is relative to the base URL of the applet. It cannot be absolute.
Also try adding the jar in the same directory as the html.
For some further information see this doc
http://docs.oracle.com/javase/1.4.2/docs/guide/misc/applet.html