Using the jswat debugger

NOTE: these instructions are geared toward Mac OSX.

Instructions for dowloading and installing

  1. Goto

  2. On the right side of the page, under the haeding "Featured dowloads", dowload jswat-4.5-installer.jar.

  3. In the directory where jswat-4.5-installer.jar resides, execute
       java -jar jswat-4.5-installer.jar
    from the command line. This will walk you through several steps -- just click through them, allowing all the default configution options to stand.

  4. You can now run the debugger by executing
    from the command line (where your-user-id) is the user ID for your account on your machine.

  5. As the above can get tedious, you may want to do the following: in your home directory /Users/your-user-id, create (or modify, if it already exists) the file .bashrc, including the line
       alias jswat="/Users/your-user-id/jswat-4.5/bin/jswat"

    After restarting, you can now run jswat by just typing jswat at the command line.

    It may be more convenient to run it "in the background" by executing

       jswat &
    from the command line.

jswat takes some time to master, but here is a "quickstart guide".

Getting started with jswat

  1. Click on the Sessions -> New Session tab.

  2. This brings up a window with several tabs.
    1. Under the Attributes tab, select a name for the session (can be quite arbitrary).
    2. Under the Classes tab, use the browser to select the directory containing your program.
    3. Under the Sources tab, also use the browser to select the directory containing your program.

  3. Click on the Window -> Sources tab -- this should open up a a window shouwing a listing of files in your choses source directory (you may have to "click to expand").

  4. In this source window, double click on the .java containing your program. You should now see a listing of your program -- you may have to readjust window sizes.

  5. Now, on the toolbar, you should click the "Start" button (a green right arrow -- hover over it to see "Start").

  6. Now set a breakpoint at the first line inside main -- you set a break point by clicking in the gray column on the left side of the program listing -- after setting a break point, you should see a pink box at the point where you clicked.

  7. Now, on the toolbar, click on the "Continue" button (a yellow arrow). This will start your program and run it until you hit your break point.

  8. At this point, you can set more breakpoints, using the Continue button as above, or you can "single step" through your program, using the "Step into", "Step over", etc., buttons on the toolbar.

  9. In the lower left corner of the main window, you can see the values of all currently visible variables -- you may have to click on the Windows -> Debugging -> Variables tab to bring up this window.

  10. There is much more that you can do -- see the corresponding help pages, and play around with it.