Stepping through the execution of a Java program

When a thread is suspended, the step controls can be used to step through the execution of the program line-by-line. While performing a step operation, if a breakpoint is encountered, execution suspends at the breakpoint, and the step operation ends.

Step over

  1. Select a stack frame in the Debug view. The current line of execution in that stack frame is highlighted in the editor in the Debug perspective.
  2. Click the Step Over button in the Debug view toolbar, or press the F6 key. The currently-selected line is executed and suspends on the next executable line.

Step into

  1. Select a stack frame in the Debug view. The current line of execution in the selected frame is highlighted in the editor in the Debug perspective.
  2. Click the Step Into button in the Debug view toolbar, or press the F5 key. The next expression on the currently-selected line to be executed is invoked, and execution suspends at the next executable line in the method that is invoked.

Run to return

  1. Select a stack frame in the Debug view. The current line of execution in the selected frame is highlighted in the editor in the Debug perspective.
  2. Click the Run to Return button in the Debug view toolbar or press the F7 key. Execution resumes until the next return statement in the current method is executed, and execution suspends on the next executable line.

Run to line

When a thread is suspended, it is possible to resume execution until a specified line is executed. This is a convenient way to suspend execution at a line without setting a breakpoint.

  1. Place your cursor on the line at which you want the program to run and select Run to Line from the pop-up menu or use Ctrl+R. Program execution is resumed and suspends just before the specified line is to be executed.
  2. It is possible that the line will never be hit and that the program will not suspend. Breakpoints and exceptions cause a thread to suspend before reaching the specified line.

Related concepts

Breakpoints
Java perspectives

Related tasks

Adding breakpoints
Launching a Java program
Resuming the execution of suspended threads
Running and debugging
Setting execution arguments
Suspending threads
 

Related reference

Debug view


 Copyright IBM Corporation 2000, 2002. All Rights Reserved.