Java Reference
In-Depth Information
6.3 Debugging an application
Now that you have a handle on breakpoints, we can look at how to analyze your
application's data in the debugger. As we mentioned earlier, the general proce-
dure for debugging is to set breakpoints in your code to suspend the VM at some
point of interest, and then use the debugger to trace the application's program
flow and examine the state of application data.
6.3.1
Executing an application under the debugger
Assuming you've met the criteria covered earlier in this chapter with regard to
compiling with debugging symbols on and so forth, you should be ready to debug
the application.
Selecting a runtime configuration
Executing an application in the debugger is similar to running your program
from IDEA . As their name applies, the Run/Debug configurations covered in
chapter 5 apply to both running and debugging your application. To debug an
application, select its runtime configuration entry in the main toolbar, and do
one of the following to launch it in the debugger:
Click the Debug icon on the main toolbar.
Select Run | Debug .
Press Shift+F9 .
Any of these actions will run your application and open the Debug tool window,
as shown in figure 6.3. In the figure, the application being debugged has been
suspended by a breakpoint. If you haven't defined any breakpoints, or you
haven't hit them yet, the debugger still appears, but it's empty except for a mes-
sage assuring you that your program is running. If you've enabled the Make
Module before running/debugging/reloading option or have linked Ant targets
to the build process, these actions take place before the application is launched.
Launching the debugger quickly
Alternatively, you can right-click inside the source code editor and select the
Debug menu option to begin debugging the currently loaded class. If there isn't a
matching Run/Debug configuration for the class, a temporary one is created for
you, using the default settings specified in your project configuration. Of course,
this option is available only if the class has a main() method.
 
 
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search