The easiest way to debug Java™ programs that run on your iSeries™ server
is to use the IBM® iSeries System
Debugger. The IBM iSeries System
Debugger provides a graphical user interface that enables you to more easily
use the debugging capabilities of your iSeries server.
For more information about using the iSeries System Debugger to debug and
test Java programs
that run on your iSeries server,
see IBM iSeries System
Debugger.
When debugging a Java program by using the interactive display
of your server, the program source displays whenever it encounters a breakpoint.
This may interfere with the display output of the Java program. To avoid this, debug the Java program
from another display. The output from the Java program displays where the Java command
is running and the program source shows on the other display.
It is
also possible to debug an already running Java program in this manner as long as it
is not using the Just-In-Time (JIT) compiler.
To
debug Java from
another display, do the following:
- The Java program must be held, while you start setting up
to debug.
You can hold the Java program by making the program:
- Wait for input from the keyboard.
- Wait for a time interval.
- Loop to test a variable, which requires that you set a value to eventually
get the Java program out of the loop.
- Once the Java program is held, go to another display
to perform these steps:
- Enter the Work with Active Jobs (WRKACTJOB) command on the command
line.
- Find the batch immediate (BCI) job where your Java program
is running. Look under the Subsystem/Job listing for QJVACMDSRV. Look under
the User listing for your User ID. Look under Type for BCI.
- Enter option 5 to work with that job.
- At the top of the Work with Job display, the Number, User, and
Job are displayed. Enter STRSRVJOB Number/User/Job.
- Enter STRDBG CLASS(classname). Classname is
the name of the Java class that you want to debug. It can either be
the class name that you specified on the Java command, or it can be another class.
- The source for that class appears in the Display Module Source
display.
- Set breakpoints, by pressing F6 (Add/Clear breakpoint), whenever
you would like to stop in that Java class. Press F14 to add other classes,
programs, or service programs to debug. For more information about setting
breakpoints, see Set breakpoints.
- Press F12 (Resume) to continue running the program.
- Stop holding your original Java program. When the breakpoints are hit,
the Display Module Source display appears on the display where the Start Service
Job (STRSRVJOB) command and the Start Debug (STRDBG) command were entered.
When the Java program ends, a Job being serviced ended message
appears.
- Enter the End Debug (ENDDBG) command.
- Enter the End Service Job (ENDSRVJOB) command.
Note: Ensure that you disable the Just-In-Time (JIT) when starting
the Java virtual
machine in the original job. This can be done with the java.compiler=NONE property.
If the JIT runs while debugging, unexpected results may occur.
See QIBM_CHILD_JOB_SNDINQMSG environment variable for
more information about this variable that controls whether the BCI job waits
before calling the Java virtual machine.