http://www.open-open.com/news/view/1ad9099

阅读目录

  • 1. Conditional Breakpoint
  • 2. Exception Breakpoint
  • 3. Watch Point
  • 4. Evaluation (Display or Inspect or Watch)
  • 5. Change Variable Values
  • 6. Stop in Main
  • 7. Environment Variables
  • 8. Drop to Frame
  • 9. Step Filter
  • 10. Step Into, Over and Return

1. Conditional Breakpoint

Hope 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 Breakpoint

In 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 Point

This 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 Values

We 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 Main

In 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 Variables

Instead of going to System properties to add an environment variable, we can conveniently add it through Edit Configuration dialog box.

回到顶部

8. Drop to Frame

This 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 Filter

When 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 Return

I 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 moves the control to next line.
  • F7 – Step Return: When done from inside a method the control will move to the calling line from where the current method is invoked.
  • F8 – Move to next breakpoint.

10个利用Eclipse调试Java的常见技巧相关推荐

  1. 10 个利用Eclipse调试Java的常见技巧

    1. Conditional Breakpoint Hope we know how to add a breakpoint. If not, just click on the left pane ...

  2. Eclipse调试Java的10个技巧【转】

    clipse调试Java的10个技巧 先提三点 不要使用System.out.println作为调试工具 启用所有组件的详细的日志记录级别 使用一个日志分析器来阅读日志 1.条件断点 想象一下我们平时 ...

  3. 在Ubuntu下利用Eclipse调试FFmpeg

    [编辑]第一步:准备编译环境 sudoapt-get update sudo apt-get -y install autoconf automake build-essential git liba ...

  4. eclipse调试java web_eclipse调试web项目

    在Eclipse中开发Web项目的首要难题就是如何进行代码调试.本文简要说明一下在Eclipse中使用Tomcat和Jetty调试Java Web项目的方法. Tomcat插件方式.Eclipse自身 ...

  5. 使用 Eclipse 调试 Java 程序的 10 个技巧

    第1条:不要调试太多 一个关于调试的疯狂声明作为开头.但它必须是要说的!尝试切分一下你那复杂的逻辑成多个独立的单元,并编写单元测试来检测你代码的正确性.我想像如下这样的流程应该是发生得非常频繁的--- ...

  6. eclipse java 程序调试_使用 Eclipse 调试 Java 程序的 10 个技巧

    - 友好的可读的对象 变量视图是使用对象的toString方法来现实对应的值.因为这个原因,如果提供友好的toString方法实现,对调试来说会非常有用.在javadoc中关于java.lang.Ob ...

  7. 使用Eclipse调试Java程序的10个技巧

    你应该看过一些如<关于调试的N件事>这类很流行的帖子 .假设我每天花费1小时在调试我的应用程序上的话,那累积起来的话也是很大量的时间.由于这个原因,用这些时间来重视并了解所有使我们调试更方 ...

  8. Eclipse调试Java的10个技巧

    先提三点 不要使用System.out.println作为调试工具 启用所有组件的详细的日志记录级别 使用一个日志分析器来阅读日志 1.条件断点 想象一下我们平时如何添加断点,通常的做法是双击行号的左 ...

  9. Eclipse调试Java程序技巧

    主要步骤.Debug As"->"Java Application".双击设置断点,F5是跳进,F6是执行下一步,F7是跳出 在看这篇文章前,我推荐你看一下Ecli ...

最新文章

  1. LabVIEW目标测量方法(基础篇—12)
  2. 卷积神经网络:VGG16 是基于大量真实图像的 ImageNet 图像库预训练的网络
  3. Python:机器学习库 sklearn
  4. 加入/ LINQ和Lambda的位置
  5. RHEL 5基础篇—了解系统的引导过程
  6. mybatis date类型映射_MapStruct 映射工具
  7. linux Figlet 转换字符字
  8. js svg语音波动动画_让动效更酷炫!4 个常见且常用的 SVG 交互动画方法
  9. python画折线图代码实现_python如何绘制分布折线图 python绘制分布折线图代码示例...
  10. Linux驱动编写(块设备驱动代码)
  11. WPF - 属性系统 (4 of 4)
  12. 入侵网络游戏服务器修改,如何入侵网络游戏服务器
  13. MySQL数据库(1):数据库 Database 基本概念
  14. C语言初学者环境配置
  15. USB - DFU(dfuse\stm32)、fastboot、dfu-util
  16. Meanshift 和 Camshift
  17. go-micro框架介绍
  18. jupyter notebook 用PPT展示代码 +插入图片
  19. DevOps 一篇入门介绍
  20. 根据流量 (Traffic) 来进行负载平衡器 (Auto Scaling Group) 的运作

热门文章

  1. Win32 汇编要点总结
  2. 图解Detours实例
  3. 【SaltStack官方版】—— STORING JOB RESULTS IN AN EXTERNAL SYSTEM
  4. Struts2 源码分析——拦截器的机制
  5. NOIP200905潜伏者
  6. iOS启动屏 ➕ 闪屏的方法
  7. 不生成Android Dependencies
  8. python 服务端渲染_客户端渲染和服务器渲染的区别
  9. python如何安装torch_PyTorch安装与基本使用详解
  10. 亚马逊 AWS 免费云服务操作流程