Reference Blog: Java Breakpoint debugging Tips

Source: Internet
Author: User

Java Breakpoint Debugging Tips:

How to debug Java program?

The first thing you learn Java , will feel IDE debugging good high-end wood has, in fact, very simple.

the following will be as simple and intuitive as possible to teach you in Eclipse debug in, other IDE The 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 program, you will need to have Tomcat or The Apache server starts in Debug mode.

It's 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 Back F7
Global single-Step skip F6
Global single-Step jump in F5
Global single-step jump in selection Ctrl+f5
Global Debug Last Boot F11
Global continue to F8
Global Single step with filter Shift+f5
Global Add / removing breakpoints ctrl+shift+b
Global Show Ctrl+d
Global Run last boot ctrl+f11
Global Run To line 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, part the IDE supports hot changes in the window and executes code.

6. The following button is the first to enter the method execution, such as you call the other method, you can enter 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 invoke the method of the original method, This is explained 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 , installation Jadclipse plugins. 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, it is Eclipse failed to automatically jadclipse Class File Viewer Set as class the default way to open a file.
in the Eclipse of the windows--> perference-->general->editors->file Associations modified in "*.class" and the "*.class without 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 the tried.

From

Https://www.cnblogs.com/tyhJava/p/5514053.html

Reference Blog: Java Breakpoint debugging Tips

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.