Step through and examine Java code

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 in the Debug view toolbar, or press the F6 key. The currently-selected line is executed and suspends on the next executable line.

    Step Over

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.

    Step Into

Step Return

The current execution point, up to the line immediately following the line that called the function, is executed. Execution stops after exiting the current function. If you issue this command from the main entry point (that is, in main(String[] args)), the program runs to completion.

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 into Selection

Step with filters

Toggle the Use Step Filters button in the Debug view toolbar, or use Shift + F5.

Use Step Filters

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 user preferences (see Window > Preferences > Java > Debug > Step Filtering). When a step action is invoked, stepping will continue until an unfiltered location is reached or a breakpoint is encountered.

Use Step Filters toggled on

With step filters, you can avoid debugging external packages that your code depends on, so that you only debug your application. The step filters affect step into and step return - and are independent of the step-by-step filters.

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 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.

    Run to Line

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.

Professional hosting     Belorussian informational portal         Free SCBCD 1.3 Study Guide     Free SCDJWS 1.4 Study Guide     SCDJWS 1.4 Quiz     Free IBM Certified Associate Developer Study Guide     Free SCJP 5.0 (Tiger) Study Guide     Free Mock Exam Engine     Free SCWCD 1.4 Study Guide     IBM Test 000-287. Enterprise Application Development with IBM WebSphere Studio, V5.0 Study Guide