Step 4: Using the Debugger to Debug the Application |
![]() Previous |
![]() Next |
Now that you have created an application that will run the UI, you will practice some simple debugging in JDeveloper as practice for debugging more complex applications.
You'll probably want to set a least one breakpoint before you start debugging, but it is not necessary. Setting a breakpoint in your source code instructs the debugger to pause at an exact location in the source code while debugging.
If you do not set a breakpoint, you can:
Or
Once you have paused the debugger, you can control specifically how you want it to reenter your code, using the Debug menu, toolbar icons, or keyboard equivalents. The step operations available to you include:
Notes:
To set a breakpoint in your source code:
Frame1.java
in the Code Editor.
If the file is closed, double-click its source node in the Navigator to open it in its default editor.
Your source code should still be open. If it is, to bring the Code Editor
for Frame1.java
to the foreground, you can double-click its
node in the Navigator, or select its entry (in this tutorial,
marked with a number 2) in the document bar. Unless you have explicitly
changed their numbering, any files you have opened are displayed in the
document bar in the order you opened them.
You can also cascade or tile your editor windows and navigate between them this way. To do so, from the main menu, choose Window | Cascade or one of the two tile options.
if
statement
.
Notice that
appears in place of the line number, indicating that an unverified breakpoint
has been set at this line in the source code. To remove a breakpoint, just
click
and the line number reappears.
To run the debugger on your source code:
Note: If the Default
Run Target dialog is displayed, you must select a Java class with a
main method to use as the default. In this case, you would select the Application1.java
class you created earlier. Click Browse and
navigate to \Workspace1\Project1\src\package1
. Select Application1.java
and click Open. On the Default
Run Target dialog, click OK to continue
debugging.
A number of things now happen:
if
statement. The If you continue clicking
Step Over, you will continue moving through the code to the next
executable line, stepping over, rather than into, the method calls.
this
and this$0
nodes. You can see each of the components and the classes they are based on.
If you expand these further, you can see their properties and the property
values. If another breakpoint was set, the program continues to that point. Without breakpoints, the debugging process will complete when you terminate the application being debugged.
Once your program has completed, the debugger process exits. When you close the application, a message to this effect appears in the Log tab within the Log window.
Now that you have practiced debugging, you are ready for the next task, Step 5: Compiling and Running the Application.