Debugging of applications in eclipse

Source: Internet
Author: User

As a programmer, program debugging is a basic skill. When IDE is not used, most program debugging is performed through logs or input statements (system. Out. println. You can display the program running track or the status of the program running to the user, and analyze and debug the program accordingly. In fact, such debugging is not very convenient. Debugging is provided in most ides, allowing you to execute a program in one step and view the status of each variable in the program during execution. You can also adjust the status value during the running process. The following uses eclipse as an example to describe how to debug a program. Note: To use the debug function provided by ECLIPSE, you must start the server (for Web applications) or run the program (for application applications) in the eclipse environment ). Debugging mainly involves the following aspects: l set breakpoints; l single-step tracking; l view the status of variables or objects; l dynamically modify the status of variables; l terminate running; l view switching; l delete a breakpoint. The following is an introduction. 10.5.1 set a breakpointThe purpose of setting a breakpoint is to stop the program at this place when running the statement. Generally, when you suspect that an error may occur somewhere, you can add a breakpoint before it. Generally, the breakpoint is added to the executable code, rather than the variable declaration statement. To add a breakpoint, double-click the left margin of the code line. 10.5.2 single-step trackingRun the program after the breakpoint is set. When the program runs to the breakpoint, it will stay in the row where the breakpoint is located. You can then perform the task in one step. Note: When the cursor stays on a row, it indicates that the row is to be executed. To perform one-step debugging, use F6. Execute the next line. If the current row is a method call and you want to enter the method to view the execution process, you can use F5. If you want to switch to the upper-level method, that is, to jump out of the current method, you can use F7. If you want to directly run to the next breakpoint, use F8 or the Green Arrow. If there is no subsequent breakpoint, the program runs directly to the end. 10.5.3 view the status of a variable or objectThe main purpose of one-step execution is to view the status of variables or objects during execution. You can view the status of a variable at any time during a single step. You can view the status of a variable in two ways: l place the cursor over the variable to be viewed (the Code must have been executed), and the value of the variable is displayed; l usually Variable Window. If this window is not displayed, you can use [Window] à [show view] à [variable] to display a window, the window displays all variables related to the current running process. You can view the status of the variables in this window. 10.5.4 change the variable valueThe value of the variable is dynamically adjusted during the running of the program. The adjustment method is as follows: l select the variable to be modified in the virables window; l click Change and select change value. A window is displayed. l enter the modified value in the window, OK. Then you can continue to execute the program. The modified variable value will be used for subsequent execution. In addition, you can modify the program at any time during program execution. After the program is modified, it will continue to be executed. 10.5.5 terminate the program runningIf an error has been found during the debugging process, or you do not want the program to continue to run down, you can terminate the program. To terminate the program, use the red button. Note: this error will stop the running server. 10.5.6 switch ViewAfter debug starts, the debug window is opened. You can switch to the development view at any time. To switch to another view, select Window> open perspective and select from the list. If the view is not displayed in the list, select others ], then select the view. 10.5.7 delete a breakpointAfter debugging, You need to delete the breakpoint. To delete a breakpoint, you can double-click the place where the breakpoint is added. If there is a breakpoint in the place where the breakpoint is clicked, you can cancel the breakpoint. If there is no breakpoint, you can add a breakpoint. L in the debugging view, select a breakpoint in the Breakpoints window, click "right", select "delete" from the pop-up menu, or click "right" and select "Remove all breakpoints ]. L in the "run" submenu of the main menu, select "Remove all breakpoints ].

For more debugging content, refer to the teaching material: Java Web programming basics tutorial chapter 15th 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.