简体   繁体   English

如何将小程序与罐中的包装一起使用

[英]How to use an applet with packages in a jar

I have an applet (Applet, not JApplet) that has a lot of classes organized into packages, including the applet itself. 我有了很多的组织成包中的类,包括小程序本身就是一个小程序(Applet的,不JApplet的)。 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: 我将其放在html(Game.html)中,如下所示:

<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. 正如你所看到的类被称为Game.class,包装游戏和罐子Game.jar。 The manifest is in Game.jar/META-INF 清单是在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 . 当我使用appletviewer Game.html ,出现错误(java.security.AccessControlException:访问被拒绝),如果打开.html,则出现ClassNotFoundException: Game.Game.class What can I do? 我能做什么?

try 尝试

<applet code="Game.Game" archive="Game.jar" width=800 height=600>
Your browser needs JAVA!!!
</applet>

Also check that the package name is really Game and not game . 还要检查软件包名称是否真的是Game而不是game

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.". applet代码属性的格式来自oracle doc“值appletFile可以采用classname.class或packagename.classname.class形式。” This file is relative to the base URL of the applet. 该文件是相对于小程序的基本URL的。 It cannot be absolute. 它不能是绝对的。 Also try adding the jar in the same directory as the html. 还可以尝试将jar添加到与html相同的目录中。

For some further information see this doc http://docs.oracle.com/javase/1.4.2/docs/guide/misc/applet.html 有关更多信息,请参阅此文档http://docs.oracle.com/javase/1.4.2/docs/guide/misc/applet.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM