Note: This Java plug-in guide describes features released prior to the Java SE 6 update 10 release. See Java Rich Internet Applications Development and Deployment for the latest information.
This section covers the following topics:
The purpose of this document is to simplify the debugging of applets. It provides techniques and suggestions for developing applets in Java Plug-in and describes some common errors encountered in applet development.
Applets should be debugged using the java debugger utility jdb. Also make sure to compile your .java files with -g option with javac. To begin debugging your applet:
Open Java Control Panel. Click Java > View. Specify the following parameters in the Java Runtime Parameters with each parameter separated by a comma as follows:
-agentlib:jdwp=transport=dt_shmem,address=jdbconn,server=y,suspend=n
See JPDA Connection and Invocation for the details on the possible runtime parameters for debugging.
Start Internet Explorer or Mozilla browser and load the page
which contains the applet to be debugged. Make sure the applet code
has been compiled with the -g
option of javac
.
Run the command jdb -attach <address>
in a DOS
command prompt. <address>
is the name mentioned in
the step. For example, if <address>
is jdbconn
, run the command as
jdb -attach jdbconn
To learn more about the Java Debugger (jdb), see The Java Debugger.
Once the jdb
is attached to the VM, you can set up breakpoints in the applet.
When the applet in the browser reaches the breakpoint, it will stop executing, and you will see the debugger waiting for your input to continue debugging.
When debugging applets in Java Plug-in, make sure that only one instance of the browser is being used for debugging using the same connection address at the same time. Otherwise, it will result in a conflict, since the Java Runtime for each instance of the browser will try to gain exclusive access to the connection address. To debug applets in both Internet Explorer and supported Mozilla browsers, run either Internet Explorer or supported Mozilla browsers with Java Plug-in, but not both at the same time.
Debugging applets in Java Plug-in with Active Desktop is discouraged because an instance of Internet Explorer will always be running in the desktop process during the lifetime of the user session.
You can use other debuggers from IDEs like Borlands JBuilder or Symantec's VisualCafe, instead of jdb. To use these debuggers, you will need to change the project option in these IDEs to attach Java Plug-in in the browser process on the same machine or remote machine. Different Java Runtime Parameters may also be required in the Java Control Panel. For more information, refer Java debugger or IDE manuals.
Java Console is a simple console window for redirecting all the
System.out
and System.err
messages. The
console window is disabled by default. It can be enabled from the
Java Control Panel or the task bar. If the console is enabled, you
will see the console window appear when Java Plug-in is used in the
browser. For more information on Java Console see Java Console
documentation.
For information on Java Console see the Java Console section of the Deployment Guide.
Both Java Plug-in and Java Web Start can print trace information into trace files. This includes log information from the JRE itself as well as everything your application may be printing to System.out
or System.err
.
To get access to trace information, follow these steps:
<JRE directory>/bin/ControlPanel
).The trace file is saved into the log directory in the Java deployment home directory. This is the place where main configuration files are kept. The location is specific to your operating system:
%APPDATA%\..\LocalLow\Sun\Java\Deployment
~/.java/deployment
The file name has the prefix javaws
or plugin
, depending on what you are running. One trace file is produced per process, but one application can be launched using several processes.
To get the maximum level of detail in the trace file, edit the deployment.properties
file (which is located in the Java deployment home directory) and add the following line:
deployment.trace.level=all
By default, a maximum of five trace files are created. The oldest trace files are automatically deleted. To change this limit of maximum number of trace files, add the following line to the deployment.properties
file:
deployment.max.output.files=<maximum number of trace files>
You can use the Java Console to view the trace log at runtime. By default, the Java console is hidden. Enable it in the Java Control Panel.
The Java Plug-in trace file records all the debug, System.out,
and System.err messages. The trace file is disabled by default but
is automatically enabled when the Java Console is enabled.
The trace file is located by default at C:\Documents
and Settings\<username>\Application
Data\Sun\Java\Deployment\log
in the user.dir
.
The trace file has the naming convention
.plugin<version>.trace
where
<version> indicates the version of Java installed on the
system.
The user.dir
directory contains various log and
trace files. In Windows 2000 and Windows XP this file is located at
the following location:
C:\Documents and
Settings\<username>\Application
Data\Sun\Java\Deployment.
The Application Data folder and its contents are hidden by default in Windows.
javaplugin.trace
propertyThis property controls whether Java Plug-in prints its trace messages during execution. This is useful to applet developers to determine what is occurring within Java Plug-in. To enable tracing follow the steps given below:
java.security.debug
propertyThis property controls whether the security system of the Java Runtime Environment prints its trace messages during execution. This is useful when a security exception is thrown in an applet or when a signed applet is not working. The following options are supported:
access
: print all checkPermission
resultsjar
: print jar verification informationpolicy
: print policy informationscl
: print permissions SecureClassLoader
assignsThe following options can be used with access
:
stack
: include stack tracedomain
: dumps all domains in contextfailure
: before throwing exception, dump the stack and domain that didn't have permissionFor example, to print all checkPermission
results
and dump all domains in context, perform the following actions:
-Djava.security.debug=access:stack
in the
Java Runtime Parameters field.Java Plug-in provides a rich set of documentation to help developers use the various features of Java Plug-in. The documentation includes a FAQ, which includes some of the most frequently asked questions by developers. Make sure you read and understand these documents before applet development, as it may save you hundreds of hours in debugging.
Although Java Plug-in provides the Java 2 Runtime Environment within Internet Explorer and supported Mozilla browsers, most of the facilities are provided by the Java 2 Runtime itself, rather than by Java Plug-in. Therefore, if a problem occurs in Java Plug-in, it may be either a problem in Java Plug-in, the Java 2 Runtime itself or a user error. It is extremely important to determine where bugs originate, as it will affect the speed of bug evaluation and fixing. Here are some suggestions for isolating bugs:
appletviewer
. Java Plug-in is
mainly derived from appletviewer
and has inherited
problems from appletviewer
as well. This step should
be performed only if the applet doesn't require specific browser
facilities that Java Plug-in provides, like HTTPS or RSA
signing.appletviewer
, it is likely
the problem is in the JRE and not in Java
Plug-in. appletviewer
, it could be either a Java Plug-in
problem or user error. Please examine the applet code to see if it
makes any assumptions about the execution environment. For example,
in appletviewer
the current directory is set to the
current directory in the shell when appletviewer
is
launched, whereas the current directory in Java Plug-in may be set
to the browser's directory. Therefore, loading resources from the
current directory may work in appletviewer
but not in
Java Plug-in.To submit a bug report, go to the Java Development Connection's Bug Database . Before submitting a bug, search the Bug Database to determine if the bug has already been reported. In some cases, a workaround may also have been suggested. If the bug is not already reported, submit a new bug report to the Java Plug-in team. In the bug report, include the following information:
appletviewer
;To submit a feature request, do so through the Report A Bug or Request a Feature page.In the feature request, please make sure the following information is included: