Where do I place the applet class files so that the browser finds them when it loads an HTML file with an APPLET tag?

John Zukowski

Unless otherwise specified, the browser will look for an Applet's .class files relative to the location of the HTML file that contains the APPLET tag. The class name is specified by the CLASS attribute of the APPLET tag.

In the simplest case where an applet is not in a package, the .class files and .html file will be located in the same directory.

If the applet is in a package, then you can think of the directory with the HTML file as the top-level of your CLASSPATH and you need to create subdirectories under that directory for each package level. For instance, if the package was com.jguru, you would need to create a com directory at the level where the HTML file was with a jguru directory under that, which then had the .class files in it.

Another way to specify where to locate the .class files is to specify a CODEBASE argument. This allows you to explicitly say where to look for the classes. For instance, if you wanted all your classes to be located in a specific directory, you can have CODEBASE="/classes" in your APPLET tag. If the CODEBASE is a machine other than the location the HTML file is loaded from, the applet is limited to talk to that machine.

Yet another way to package your classes is to use a JAR file, which is supported by both IE and Netscape browsers, or a .CAB file which is IE specific. These require you to use the ARCHIVE parameter or CABINETS parameter, respectively.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact