house fly

JSwat Project

How To: Applet Debugging


Attaching to a Running Applet

To debug an applet that is already running, you must have started that applet using a command line like the following:

% appletviewer -J-Xdebug -J-Xnoagent -J-Djava.compiler=NONE -J-Xrunjdwp:transport=dt_socket,server=y,suspend=n <applet.html>

This will start the appletviewer with the JPDA debugger back-end and run the applet using the given HTML file. The socket transport will be used and the back-end will act as the server. This allows JSwat to connect to the debugger back-end by using the 'attach' JSwat command. The debugger back-end will print a four-digit number in the command shell where you invoked 'appletviewer'. This is the socket port number that JSwat must connect to.

Once you have started JSwat and the debuggee applet is running, you can type "attach <port>" to attach to the debugger back-end through the given port number. JSwat should say "VM attached" when successful.

Detaching from a Running Applet

To end the remote debugging session, invoke the command 'detach' or 'close'. Either one of these commands will close the connection with the debuggee VM and leave it running. If you invoke the 'kill' command instead, this will terminate the debuggee VM.

Listening for a Connection

In addition to connecting to an already running remote VM, JSwat can listen for connections from new VMs. This is done using the 'listen' command. It takes an optional port number to listen to, or uses a default as generated by the JPDA. While JSwat is listening for a remote VM to connect, you may launch the remote debuggee using something like the following:

% appletviewer -J-Xdebug -J-Xnoagent -J-Djava.compiler=NONE -J-Xrunjdwp:transport=dt_socket,address=<port> <applet.html>

For the <port> value, substitute the value returned from the 'listen' command. Enter the name of the applet HTML file in place of the <applet.html> argument. Once the remote VM starts up, JSwat will activate a new debugging session and will be ready for your input.

For More Information

Check out the thorough documentation available for the JPDA libraries. These docs come with the JDK documentation for JDK 1.3 and above. Be sure to read up on the JPDA connectors to learn all the options when remotely debugging.



Back to Documentation