javajarappletappletviewer

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. 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?


Solution

  • 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