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. If a breakpoint is encountered while performing a step operation,  the execution will suspend at the breakpoint and the step operation is ended.

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 [ Step Over ] in the 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 [ Step Into ] in the 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.

Step into Selection

  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. In the Java Editor, within the current line of execution, place the cursor on the name of a method that you would like to step into.
  3. Click the Step into Selection action in the Run menu or Java editor context menu, or press the Ctrl-F5 key. Execution resumes until the selected method is invoked.

Step with filters

  1. Toggle the Use Step Filters button [ Use Step Filters ] in the Debug view toolbar, or use Shift+F5. When the action is toggled on, each of the step actions (over, into, return) will apply the set of step filters which are defined in the Opens the Step Filtering preference page Java > Debug > Step Filtering preference page. When a step action is invoked, stepping will continue until an unfiltered location is reached or a breakpoint is encountered.

Step 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 Step Return button [ Step Return ] in the 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.
  2. Select the Run to Line command [ 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.

It is possible that the line will never be hit and that the program will not suspend. 

Breakpoints and exceptions can cause the 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