Applet packaged as .cab file results in java.lang.ClassNotFoundException thrown when applet runs.


Symptoms

When running an applet in a browser using the Sun JRE, a ClassNotFoundException is thrown by the ClassLoader. The same applet runs under the Microsoft VM.

Cause

This error is caused by applets being packaged as .cab files. The .cab file is an archive format specific to Microsoft Windows, and it is not supported by the Sun JRE.

Resolution

The workaround is to extract the applet classes and resources from the .cab files and repackage them as .jar files using the jar tool from JDK:

        jar cvf <jar_file> <input_files>

The <APPLET> tag in the HTML page will also need to be modified to specify the .jar files in the archive attribute. For example,

        <APPLET code="MyApplet" width=100 height=100>
        <PARAM name="cabbase" value="package1.cab, package2.cab"> 
    </APPLET>

        should be modified as follows:

<APPLET code="MyApplet" archive="package1.jar, package2.jar" width=100 height=100>
</APPLET>

Related Information

        Please refer to the JAR tool documentation for more details.