Assigning a code base for a common resource location


What is a code base?

A codebase works with the code attribute in the <APPLET> tag to specify where to find the applet class files, specifying the URL of the directory containing the files to use.

Why use a codebase?

Using resources common to all pages can significantly improve the performance of Java applets.

Resource links

When no codebase is defined, the applet assumes all resources to be in the same directory as the current document. If a codebase is defined, the applet assumes ALL resources to be in the nominated folder. Care is needed here to not mix links, for example if the applet is to look for the Java class files in the codebase folder, then the image cannot be elsewhere. It must also be in the codebase folder.

Defining a codebase

If all CopySafe files are in the same folder then that folder automatically becomes the codebase for the applet. If delivering on the fly from templates or storing your html in a different folder to your image files, you need to set a codebase in the applet.

<APPLET codebase=/classfiles code=ArtistScopeViewer.class archive=ArtistScopeViewer.jar width=300 height=200 id=ArtistScope>

All image and java class files must be in the 'codebase'. Altering the image link in the applet code will not work. Relocation must be by codebase statement.

Return to top

facebook
twitter
email