马特波莫和他ceo老公:Java Debugging with Eclipse - Tutorial
来源:百度文库 编辑:九乡新闻网 时间:2024/05/01 16:31:44
Java Debugging with Eclipse - Tutorial
Lars Vogel
Version 1.3
Copyright ? 2011 Lars Vogel
25.06.2011
Eclipse Debugging
This article describes how to debug a Java application in Eclipse.
This article is based on Eclipse 3.7 (Eclipse Indigo).
Table of Contents
- 1. Overview
- 2. Example
- 3. Debug
- 3.1. Setting Breakpoints
- 3.2. Starting the Debugger
- 3.3. Stack
- 3.4. Variables
- 4. Advanced Debugging
- 4.1. Skip all breakpoints
- 4.2. Breakpoint Properties
- 4.3. Watchpoint
- 4.4. Exception Breakpoint
- 4.5. Method Breakpoint
- 4.6. Class breakpoint
- 4.7. Hit Count
- 4.8. Drop to frame
- 5. Thank you
- 6. Questions and Discussion
- 7. Links and Literature
- 7.1. Source Code
- 7.2. Debugging Links
- 7.3. vogella Resources
1. Overview
The installation and usage of Eclipse as Java IDE is described in Eclipse Java IDE
This article will focus on how to debug Java applications in Eclipse.
4. Advanced Debugging
4.1. Skip all breakpoints
If you want to temporary de-activate all your breakpoints you can press the button "Skip all breakpoints" which is visible if you select the tab breakpoints.
If you press this button again the breakpoints will get activated again.
4.2. Breakpoint Properties
After setting a breakpoint you can select the properties of the breakpoint to for example use a condition to restrict when the breakpoint should get toggeled. In the properties you can for example restrict that the breakpoint should only be executed the 12 hit (Hit Count) or you can put in a conditional expression (which you can also use for logging if you want).
4.3. Watchpoint
A watchpoint is a breakpoint at which is stop whenever a field read or changed. You can set a watchpoint through a double-click on the left side before the field declaration. Via the properties of the watchpoint you can define if the breakpoint should be hit during read access (Field Access) or during write access (Field Modification).
4.4. Exception Breakpoint
The application is stopped if the specified exception is thrown. To define an exception breakpoint click on the following icon.
You can define if you want to stop and caught and / or uncaught exceptions.
4.5. Method Breakpoint
A method breakpoint is defined via double-click in the left border of the editor and the method head. You can define if you want to stop the program during method entry of after leaving the method.
4.6. Class breakpoint
A Class Load Breakpoint will stop when the class is loaded. Right-click on a class in the Outline View and choose "Toggle Class Load Breakpoint"
4.7. Hit Count
For every breakpoint you can define via the properties the hit count. If you use the hit count then the application is stop then the breakpoint is reached the number of times defined in the hit count.
4.8. Drop to frame
Eclipse allows you to select any level (frame) in the call stack during debugging and set the JVM to restart to that point.
This allows you to rerun a part of your program. Be aware that variables which have been modified by the code which you reset remain modified. The drop to frame will return to the the code. Changes made by the code, e.g. to variables / databases will not be reset.
To use the feature select the level in your stack and press the highlighted button.
5. Thank you
Please help me to support this article:
6. Questions and Discussion
Before posting questions, please see the vogella FAQ . If you have questions or find an error in this article please use the www.vogella.de Google Group . I have created a short list how to create good questions which might also help you.
7. Links and Literature
7.1. Source Code
Source Code of Examples
7.2. Debugging Links
http://www.eclipse.org/articles/Article-Debugger/how-to.html How to develop your own debugger
7.3. vogella Resources
Eclipse RCP Training (German) Eclipse RCP Training with Lars Vogel
Android Tutorial Introduction to Android Programming
GWT Tutorial Program in Java and compile to JavaScript and HTML
Eclipse RCP Tutorial Create native applications in Java
JUnit Tutorial Test your application
Git Tutorial Put everything you have under distributed version control system