已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Top 10 Java Debugging Tips with Eclipse30/08/2012来源:/core-java/top-10-java-debugging-tips-with-eclipse/In this tutorial we will see about debugging java applications using Eclipse. Debugging helps us to identify and fix defects in the application. We will focus on run-time issues and not compile time errors. There are command line debuggers like gdb available. In this tutorial we will focus on GUI based debugger and we take our favourite IDE Eclipse to run through the tutorial. Though we say Eclipse, the points are mostly generic and is suitable for debugging using most of the IDEs like NetBeans too.Before going through this tutorial, I recommend you to have a look at Eclipse shortcuts and it will really help. My Eclipse version is Juno as of writing this tutorial. Do not use System.out.println as a tool to debug. Enable detailed log level of all the components involved. Use a log analyzer to read logs.1. Conditional BreakpointHope we know how to add a breakpoint. If not, just click on the left pane (just before the line number) and a breakpoint will be created. In debug perspective, Breakpoints view will list the breakpoint created. We can add a boolean condition to it. That is, the breakpoint will be activated and execution will hold only if the boolean condition is met otherwise this breakpoint will be skipped.2. Exception BreakpointIn Breakpoints view there is a button labeled as J! We can use that button to add a java exception based breakpoint. For example we want the program to halt and allow to debug when a NullPointerException is thrown we can add a breakpoint using this.3. Watch PointThis is one nice feature I love. When a chosen attribute is accessed or modified program execution will halt and allow to debug. Select a class variable in Outline view and from its context menu select Toggle Watchpoint. This will create a watch point for that attribute and it will be listed in Breakpoints view.4. Evaluation (Display or Inspect or Watch)Ctrl+Shift+d or Ctrl+Shift+i on a selected variable or expression will show the value. We can also add a permanent watch on an expression/variable which will be shown in Expressions view when debug is on.5. Change Variable ValuesWe can change the value of a variable on the fly during debug. Choose a variable and go to Variables view and select the value, type and enter.6. Stop in MainIn Run/Debug Settings, Edit Configuration we can enable a check box that says Stop in main. If enabled when we debug a java program that launches with a main method, the execution halts at first line of main method.7. Environment VariablesInstead of going to System properties to add an environment variable, we can conveniently add it through Edit Configuration dialog box.8. Drop to FrameThis is the second best feature I love. We can just return the control to any frame in the call stack during debug. Changes made to variables will not be reset. Choose the stack level which you want to go back and restart debug from there and click the drop to frame button from debug toolbar. Eclipse is cool!9. Step FilterWhen we Step Into (F5) a method we may go into external libraries (like java) and we may not need it. We can add a filter in preferences and exclude packages.10. Step Into, Over and ReturnI kept this as the last point as this is the first thing to learn in debugging :-) F5 Step Into: moves to next step and if the current line has a method call the control will go into the first line of the called method. F6 Step Over: moves the control to next line. If there is a method call in the current line, it executes the method call internally and just
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 可行性研究报告与设计任务书
- 家畜环境卫生学第四章
- 2025年新疆全民科学素质竞赛学习试题库及答案(共720题)
- 商务英语口语表达技巧
- 2024北京一六一中高三10月月考化学试题
- 安全标志管理员安全生产标准化建设方案
- 护理岗位职业规划与面试策略
- 地质行业勘探技术与资源开发策略
- 客户关系管理策略制定与实施安排
- 工业污水处理技术与案例分析
- ICU呼吸机应用操作指导
- 移动客服沟通话术
- 高中体育人教版 (2019)全一册第三章 培养体育品德第三节 体育品格教学设计
- 仓管转正述职报告
- 门店拓客引流课件
- (2025年)医院药房的考试试题及答案
- 《氯代烃污染地下水原位生物及化学修复技术指南》
- 2025年工业产品市场推广代理合同协议
- 贵州国企笔试题库及答案
- 2025年中国射频模组行业市场集中度、企业竞争格局分析报告-智研咨询发布
- 电子厂生产流程及管理规范
评论
0/150
提交评论