Starting a Local Debugging Session
Local debugging is the process of debugging a program that is running on the
same computer as the IDE. The IDE starts the debugger, then runs the
application inside the debugger. When you start a debugging session, the IDE
automatically opens the debugger windows and prints debugger output to the
Output window.
Debugging the Main Project
All of the debugging commands in the Run menu are run on the main project.
No matter what file or project is selected in the Projects window or Source
Editor, these commands begin the debugging session in the main class of the
main project.
|
Command
|
Shortcut
|
Description
|
|
Run > Debug Main Project
|
Ctrl-F5 or
|
Runs the program until it reaches a breakpoint or
exception or until the program terminates normally.
|
|
Run > Step Into
|
F7 or
|
Runs the program to the first line after the main routine and pauses execution before
any changes have been made to the state of the program.
|
|
Run > Run to Cursor
|
F4 or
|
Runs the program to the cursor location in the Source
Editor and pauses the program. The file you have selected in the Source
Editor must be called from the main class of the main project.
|
Debugging an Individual Project
- Right-click the project in
the Projects window and choose Debug Project.
The IDE runs the project in the debugger until
execution stops or a breakpoint is reached.
Debugging an Individual File
- Select any runnable file in
the Projects window and choose Run > Run File > Debug my_file.
The IDE runs the file in the debugger until
execution stops or a breakpoint is reached.
Starting a Remote Debugging Session
Remote debugging is the process of debugging an application that is running
on a different computer. This technique is useful when you are developing an
application that runs on a web server or on a different environment than the
computer on which you are developing the application.
To start a remote debugging session:
- On the computer where the
application is located, start the application in debugging mode. See your
VM documentation for instructions on starting an application in debugging
mode. For the Sun Microsystems Java Virtual Machine, the options can be
found at:
http://java.sun.com/products/jpda/doc/conninv.html - On
the computer where the IDE is running, open the projects that contain the
source for the application.
- Choose Run > Attach
Debugger.
- Select the connector type
and enter any required process information, then click OK. See your VM
documentation for information about the connectors it provides.
About Debugging and Testing Web Applications
At the end of the development cycle, you need to debug and test your web application. The IDE has a number of features that help you to do so. The following are the most important ones:
- Detection of syntax problems in JSP files during compilation.
- Viewing the translated servlet after deployment.
- JUnit testing.
- Using the debugger to debug web applications, JSP files, and servlets.
- Using the profiler to profile web application performance and check for memory leaks.
- Monitoring by means of the HTTP Monitor. When you run web applications, JSP files, or servlets, the HTTP Monitor can gather data about HTTP requests that the servlet engine processes. For each HTTP request that the engine processes, the monitor records data about the incoming request, the data states maintained on the server, and the servlet context. You can view data, store data for future sessions, and replay and edit previous requests.
- Writing a target to debug and test free-form web projects.
Debugging a Web Application
You can use the Sun
Microsystems JPDA debugger from the IDE to debug web applications, servlets, and JSP files. Just as with Java
programs, the IDE enables you to set new watches, evaluate a variable by
holding the cursor over the variable, and set breakpoints in JSP files, JSP
documents, and JSP segments. A tag file is debugged when
you debug the JSP file that references it.
The method that you use to start a debugging session depends on the type of
web component that you want to debug.
To debug a web application:
- Set breakpoints and watches
in the web application's JSP files, servlets, and other source files.
- If necessary, specify request parameters
in the JSP files and servlets.
- Right-click the project
node in the Projects window and choose Debug Project from the pop-up menu.
To debug a JSP file:
- Set breakpoints and watches
in the JSP file and, optionally, its tag files.
- If necessary, specify request parameters
in the JSP file.
- Right-click the JSP file's
node and choose Debug File. Optionally, choose Run > Run File >
Debug file.jsp (Ctrl-Shift-F5) from the main menu.
When you change a JSP file while in a debugging
session, you do not need to start a new debugging session. Just reload the
page.
To debug a servlet:
- Set breakpoints and watches
in the servlet.
- If necessary, specify request parameters
in the servlet.
Right-click the servlet's node and choose Debug File.
Optionally, choose Run > Run File > Debug file.java
(Ctrl-Shift-F5) from the main menu.
-- Wagner R. Santos