Commands

Much of the functionality of JSwat lies in two places: the graphical user interface and the command interface. The command interface is accessible both in JSwat's "console" mode and in its default graphical mode. In graphical mode, the command interface is made up of the "Messages" text area and the "Command" text field. Commands are entered in the text field and the results are displayed in the messages area.

To get familiar with the many JSwat commands, I recommend running the help command after starting JSwat. This will present you with various categories of commands and let you browse through the categories. You can learn what commands are used for manipulating breakpoints, single-stepping, and many other debugging-related operations.

Arguments

Many commands take one or more arguments. The command arguments follow the name of the command, separated by spaces. Multiple spaces are irrelevant. Arguments may be enclosed in single or double quotes (' or "). Quoting the arguments is useful when passing arguments that contain spaces. Some commands have exceptions to their acceptance of quoted arguments, and they are clearly indicated in the command help.

History

Commands are stored in a "history chain" and can be invoked using the !<prefix> and !! operators. Earlier commands can be recalled using the up and down cursor keys (or Ctrl-p and Ctrl-n keys) to move backward and forward through the command history. (Note, this feature is not available in console mode.)

Aliases

Commands can be aliased to other names, offering you the ability to make the interface more convenient. Both a command and its arguments can be stored as an alias. The alias is invoked by the alias name, and may include additional arguments to the original command. Use the alias and unalias commands to manage aliases.

Aliases can be used as a form of "macro". That is, an alias can be made up of multiple commands, separated by semicolons. Invoking multiple commands is described below.

Invoking Multiple Commands

The JSwat command interpreter understands using the semicolon (;) character to separate multiple commands on a single command line. For instance, the following input string would be interpreted as two separate commands, executed in series.

classpath "c:\classes" ; sourcepath "c:\source"

Because of this special separator character, you must be careful to quote any command arguments that contain the separator. For instance, the following would be misinterpreted as two commands.

classpath c:\classes;d:\stuff.jar

The proper way to run that command would be to enclose the classpath argument in quotes, like so:

classpath "c:\classes;d:\stuff.jar"

Note that the backslash (\) character causes the subsequent character to be treated as a normal character. That is, if the sequence "\;" is parsed, the semicolon will have no special significance. This can be useful if you need to escape a quote character or perhaps a backslash.

Startup File

JSwat processes what is often called a startup file. That is, when JSwat is started, it looks for a file with a particular name and processes it. This file may contain JSwat commands to be executed when JSwat starts. The file is called .jswat/init and lives in your home directory. JSwat also looks for a file named jswat.init in the current directory, and each parent directory until it reaches of the root of the file system, processing the files in the order they are found.

Here is an example of a startup file.

#
# Lines starting with the # character are ignored.
#

# Create some useful command aliases.
alias   go              resume
alias   cont            resume
alias   quit            exit
alias   finish          step out

# Set the path where jswat looks for source files.
sourcepath /usr/java/src