How to Suspend Execution of a Java Class while Debugging
When you launch a Java class in debug mode, it runs until the execution is suspended. When the execution is suspended, Designer switches to the Debug perspective, allowing you to use the views in the perspective to inspect the state of the Java class. If the execution is never suspended, the Java class runs from beginning to end without switching to the Debug perspective, and as a result, never allowing you to inspect the state of the Java class in the middle of execution.
To suspend the Java class, you must do at least one of the following before launching the Java class in debug mode:
Set breakpoints in the Java class. To set breakpoints, open the Java service in the Java service editor and double click in the left margin next to the executable lines of code where you want breakpoints.
Designer displays the breakpoint enabled icon (
) in the margin.
When you launch the Java class in debug mode and the debugger encounters a breakpoint, it suspends execution. At that time, if the Debug perspective is not already in use, Designer switches to it. The Debug view will show the test harness class and be positioned at the statement for which you created the breakpoint.
Select “Stop in main” in the Java Application launch configuration. Create or update the Java Application launch configuration that you want to use for debugging the Java class so that the Stop in main check box is selected on the Main tab.
When this option is selected and you launch the test harness in debug mode, the debugger suspends execution at the first executable line in the main method of the test harness, and Designer switches to the Debug perspective. The Debug view will show the test harness class and be positioned at the first statement in the main method. Also, the test harness will be opened in the Java editor, and it will be positioned to the first executable line in the main method.
When a Java class is suspended, use the views in the Debug perspective to inspect the state of the Java class and the actions in the Debug view toolbar to resume the execution. For more information about using the debugger, see the Eclipse Java Development User Guide.