Debugging for Applications in eclipse

Source: Internet
Author: User
Tags java web
As a programmer, the debugging of a program is a basic skill. When you do not use the IDE, the debugging of a program is mostly through a log or input statement (SYSTEM.OUT.PRINTLN). The program can be run by the track or the state of the program to display the status of the user, the user to the program analysis and debugging. In fact, such debugging is not very convenient. The debug feature is available in most Ides, allowing users to step through the program and view the status of variables in the program during execution. The value of the state can also be adjusted during the program's operation. The following is an example of Eclipse, which describes how to use the Debug debugger. Note: To use the debug functionality provided by Eclipse, you must start the server in the Eclipse environment (for Web applications) or run the program (apply to application). Debugging mainly involves the following aspects: L Set Breakpoints, L step tracking, L View the status of variables or objects, L dynamically modify the state of variables, l terminate operation, l view switch; L Delete Breakpoints. The following are described separately. 10.5.1 Set BreakpointsThe purpose of setting a breakpoint is to let the program run into this statement when it stops in this place. In general, when you suspect that a place may be wrong, you can add a breakpoint before this place, and usually the breakpoint is added to the executable code, not the variable's declaration statement. To add a breakpoint, double-click in the left margin of the line of code. 10.5.2 Single Step trackingAfter you set a breakpoint, you run the program, and the program stays on the line where the breakpoint is running. You can then step through it. Note: When the cursor hovers over a line, it indicates that the line is ready to execute. To step through debugging, use F6. Executes the next line. You can use F5 if the current row is a method call and you want to enter the method to see the execution process. You can use F7 if you want to move up the first-level method, which is to jump out of the current method. If you want to run directly to the next breakpoint, use the F8, or the green arrow. If there are no subsequent breakpoints, the program runs directly to the end of the place. 10.5.3 View the state of a variable or objectThe primary purpose of stepping is to view the state of variables or objects during execution. You can view the state of a variable at any time during stepping. There are two ways to view the state of a variable: L put the mouse over the variable to be viewed (must be the code that has already been executed) to display the value of the variable; l usually variable the window, and if the window doesn't show up, you can go through the "window" à-Vie W "à" Variable, this will appear a window, the window shows all the current running process-related variables, you can view the status of variables through this window. 10.5.4 Change the value of a variableDynamically adjusts the value of a variable while the program is running. The adjustment method is as follows: L Select the variable to be modified in the Virables window; l Click on right, select Change value, pop-up window, l enter the modified value in the window, OK. You can then continue to execute the program. Subsequent execution uses the value of the modified variable. In addition, in the process of program execution can modify the program at any time, modify the program will continue to execute. 10.5.5 Terminate program runIf you have found an error during debugging, or you do not want the program to continue down execution, you can terminate the program. To terminate the program, you can use the Red Square button. Note: This error will stop the server running at that time. 10.5.6 Toggle ViewAfter debug starts, the Debug window opens. You can switch to Development view at any time. To switch to another view, select "Window" à "Open perspective" and select from the list, and if you do not see the corresponding view in the list, you can select "Others" and select the appropriate view from it. 10.5.7 Delete BreakpointsAfter debugging is finished, you need to remove the breakpoint. To delete a breakpoint, you can do the following: L Double-click where you want to add a breakpoint, and if you double-click a breakpoint, you can cancel the breakpoint, and if there is no breakpoint, you can add a breakpoint. L Select a breakpoint in the Breakpoints window in the Debug view, click Right, select Delete from the pop-up menu, or click right to select Remove all breakpoints.  L Select Remove all breakpoints in the "Run" submenu on the main menu. More about debugging, reference materials: "Java Web Programming Basics Tutorial," The 15th Chapter program debugging
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.