java.lang.ClassNotFoundException Thrown by ClassLoader

Symptoms

When running an applet in a browser by using the Sun Java™ Runtime Environment (JRE™) implementation, a java.lang.ClassNotFoundException is thrown by the ClassLoader. The same applet runs without any error under the Microsoft Virtual Machine (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

Extract the applet classes and resources from the .cab files and repackage them as .jar files using the Java Archive File Format (JAR™) tool from Java Development Kit (JDK). Type the following command to repackage files as .jar files:

        jar cvf <jar_file> <input_files>

Modify the <APPLET> tag in the HTML page to specify the .jar files in the archive attribute. For example, assume you have the following code:

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

        You can modify the above code as shown in the following example:

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

Related Information

        See the JAR tool documentation for more details.


Copyright © 1993, 2011, Oracle and/or its affiliates. All rights reserved.