cattails

Blue Marsh Softworks

 Site Index
 o java projects
 o about me
 o search

 My Java
 o java tips
 o java faq
 o contributing
 General Java
 o JavaSoft
 o Developer Connection
 o The Java FAQ
 o Java Glossary

 JSwat
 o download
 o documentation
 o faq
 o mail lists
 o contributing
 o bugs
 Related Software
 o JPDA
 o Emacs JDEE
 o JDBTool
 o jEdit plugin
 o Jenus
 o NetBeans
 Related Links
 o Top Ten Reasons Not to Use a Java Debugger in School

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 (the trailing slash indicates that the two lines below should be entered as one line):

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 referenced in 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 command. The debugger back-end will print a four-digit number in the command shell where you invoked appletviewer. This is the 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 close command. This 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 (the trailing slash indicates that the two lines below should be entered as one line):

% 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 the debugging session and will be ready for your input.

For More Information

Check out the thorough documentation available for the JPDA library. 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.

© Copyright 2000-2002 - Blue Marsh Softworks