Java Eclipse for Breakpoint debugging

Source: Internet
Author: User

How do I debug a Java program?

Everyone began to learn Java, will feel that the IDE debugging good high-end wood has, in fact, very simple.

The following will be as simple and intuitive as possible to teach you to debug in Eclipse, and other IDE debugging steps are similar.

1. Set a breakpoint where you feel it is wrong.

Before the number of lines of code, right-click, pay attention to the right button, and select Toggle Breakpoint.

You might ask, how do I know where to place breakpoints?

    • If you have no sense of the problem at all, you can hit a few more breakpoints, one-step debugging until you find the exception, just spend a little more time, and this can be more in-depth understanding of the program's execution process!
    • Of course, you can set breakpoints here if you can roughly go where the problem may be, or if the exception information reports the class location.

2. Click Debug, if it is a Web application, you will need to start the Tomcat or Apache server in debug mode.

This is important, the standard start mode, can not enter the pre-set breakpoints, it will not be able to achieve the purpose of debugging.

3. Run the program, and when the program runs to the location where you just set the breakpoint, it will stop and the line of code will be highlighted.

At this time, you can use the screen button or keyboard control program.

Here is the keyboard for debugging shortcut keys, if it does not work, you can check whether keyboard conflicts .

For example, Youdao dictionary shortcut keys, often and Debud mode of the resume conflict.

scope function Shortcut keys

Global single-Step return F7
Global single-Step skip F6
Global single-step jump into F5
Global single-Step jump selection Ctrl+f5
Global Debug Last started F11
Global Continue F8
Global use filters to step SHIFT+F5
Global Add/Remove breakpoints Ctrl+shift+b
Global Display Ctrl+d
Global Run last boot ctrl+f11
Global Run to row ctrl+r
Global Execution Ctrl+u

4. Go to the debug screen to see the information you want.

5. In variables, you can see the values of all variables, such as the value of the breakpoint you just set, right-ChangeValue can be changed, some IDES support hot changes in the window and execute code.

6. The following button is the first to enter the method execution, such as you call the other method, you can go to the method step by step execution, if you click the second button, only in this method step by step execution, the third button when you jump out of this method, continue to execute the original method of calling this method, described below.

7. Execute the procedure.

8. Add the anti-compile plugin for Eclipse for better debugging

In general, our projects will more or less refer to some external jar packages, if you can view the source code of the jar package, for our debugging can be said to be more than a multiplier.

1, download and install Jad.exe. extract the Jad.exe to the program directory (can be placed in any directory), for example: C:\Program files\jad\jad.exe.

2, install Jadclipse plug-in. download and unzip the Net.sf.jadclipse_3.3.0.jar, copy it to the Eclipse\plugins directory, and restart Eclipse.

3, Configuration jadclipse. under the Eclipse window, click Window > Preferences > Java > Jadclipse > Path to Decompiler.
(Set absolute path to Jad, e.g. C:\Program Files\jad\jad.exe)
You can tick the use Eclipse code formatter (Overrides Jad formatting instructions) option so that it matches the code style of the CTRL+SHIF+F format.

After performing these steps, and then clicking View on the classes or methods imported from the jar, you can view the source code, if not, refer to the following workaround:

In most cases, Eclipse failed to automatically set the Jadclipse class file viewer to the default open mode for class files.
Modify "*.class" and "*.class without" in Eclipse's windows--> perference-->general->editors->file associations SOURCE "The default associated editor is" Jadclipse Class File Viewer ".
has been configured a few times Jad plug-ins, if not anti-compilation, so set, after all.

From

Http://www.cnblogs.com/binyue/p/3324524.html

Java Eclipse for Breakpoint 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.