When Java Applets Fail to Load

The following is a modified version of http://navsurf.com/articles/error_messages.asp:

When a Java applet fails to load correctly, the browser will often display an error message that contains important information to the source of the failure. The error message is either displayed on the status bar, the Java console or both. Status bar messages are often sufficient to determine the cause of error. You may also wish to opening the Java console to get a full description of the error in order to report the problem to the author of the applet. Note that this article applies to all Java applets and not only NavSurf applets.

Check to see if Java is enabled

Applet refuses to load? Before you start, check to see that Java is enabled on the browser. Although it is enabled by default on all browsers, it may be accidentally disabled.

Activating and opening the Java console

If you are still having trouble, you should turn on your java console in your browser. Error messages are placed there to hide them from non-technical viewers, but you will want to see them to help you debug your problem:

If you are using Internet Explorer, you can open the Java console by clicking on View -> Java console. If the "Java console" option is absent, you can activate it by going to Tools->Internet Options->Advanced->Microsoft VM and checking the option "Java console enabled".

If you are using Netscape Communicator 4.x, you can open the Java console by clicking on Communicator -> Tools -> Java console or Communicator -> Java console, depending on the version of the browser.

If you are using Netscape 6, you can open the Java console by clicking on Tasks -> Tools -> Java console.

Common Error Messages

Now that the console window is open, try to reload your applet. The most common error messages are outlined below:

class applet_name not found
java.lang.ClassNotFoundException: applet_name

The applet files are not found. Verify that the files are placed in the correct directory. If you want to put the directory in another directory, specify the name of the directory in the codebase attribute. Putting the directory in the code attribute would cause an error.


java.lang.NoClassDefFoundError : applet_name
class class_name got a security violation: method verification error

One or more methods used by the applet is not found in the Java library files of the browser. This could mean one of the following problems:


java.lang.ClassFormatError: Bad magic number

The applet is corrupted or uploaded to the server in the text or ascii mode instead of the binary mode. Solution: Download the applet files again and upload them to your server in binary mode.


java.lang.ClassNotFoundException: applet_name$class_name

This error message is usually accompanied by another problem - The applet works on the hard disk but not when the files are uploaded to the server. The problem is due to the server not accepting filenames containing "$". Solution: Place the applet files in a zip archive. Please refer to the section on the <applet> tag and reducing applet download time for more information.

This should cover most of the common error messages that Java applet users encounter. Please feel free to contact me if you feel that I have left out some error messages or if you have any comment or suggestion.



NavSurf.com
December 2000