Debug a Java program

The easiest way to debug Java™ programs that run on your iSeries™ server is to use the IBM® iSeries System Debugger. 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.

If you want, you can use the interactive display of your server to use the *DEBUG option to view the source code before running the program. Then, you can set breakpoints, or step over or into a program to analyze errors while the program is running.

To debug Java programs, follow these steps:

  1. Compile the Java program by using the DEBUG option, which is the -g option on the javac tool. See Debug Java programs by using the *DEBUG option for more details.
  2. Insert the class file (.class) and source file (.java) in the same directory on your iSeries server.
  3. Run the Java program by using the Run Java (RUNJVA) command on the iSeries command line. Specify OPTION(*DEBUG) on the Run Java (RUNJVA) command.

    Only a class may be debugged. If a JAR file name is entered for the CLASS keyword, OPTION(*DEBUG) is not supported.

  4. The Java program source is displayed.
  5. Press F6 (Add/Clear breakpoint) to set breakpoints, or press F10 (Step) to step through the program. For more information about setting breakpoints, see Set breakpoints. For details on stepping, see Step through Java programs to debug.

Tips:

  1. While using breakpoints and steps, check the logical flow of the Java program, then view and change variables, as necessary.
  2. Using OPTION(*DEBUG) on the RUNJVA command disables the Just-In-Time (JIT) compiler. Files that do not have an associated Java program run in interpreted mode.