Monday, August 10, 2009

JSwat

I've always been a fan of software tools that stick to their knitting.

I've been using JSwat as my Java debugging tool for close to a decade. It works and I'm comfortable with it, and I don't see the need to change. There are plenty of other Java debugging tools available, so you should use whichever one you're most comfortable with.

But if you decide you want to try JSwat, here's a capsule summary:

  1. Install it from the project home: http://code.google.com/p/jswat/
  2. When you start any Java program that you wish to debug, pass these flags on the command line:

    -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5000

  3. In JSwat, use the "Session -> Settings" dialog to add your various source code paths to the debugger. For example, if you are working with Derby code and you want to debug it, add the trunk/java/engine folder. You should only have to do this once and then JSwat remembers it.

  4. Then use "Session -> Attach" to attach to your Java program to debug it. You will have to choose port 5000 in the attach dialog.

Then you should be able to set breakpoints, view the values of variables, etc.

It takes a little while to learn how to use the debugger, so it's good to practice.

And read the debugger's built-in help files, which are quite helpful and clear.

No comments:

Post a Comment