`
fly_hyp
  • 浏览: 296408 次
  • 性别: Icon_minigender_1
  • 来自: 合肥
社区版块
存档分类
最新评论

Java Debug 工具使用技巧

 
阅读更多

Java 这种半解释半编译语言,他的调试工具应该是不比强大的,做成Javaer 应该精通使用它。

 

http://javarevisited.blogspot.com/2011/07/java-debugging-tutorial-example-tips.html

 

1) Use conditional breakpoint

Eclipse allows you to setup conditional break point for debugging java program, which is a breakpoint with condition and your thread will only stop at specified line if condition matches instead of just stopping on that line like in case of line breakpoint. To setup a conditional breakpoint just double click on any line where you want to setup a breakpoint and then right click --> properties and then insert the condition. Now program will only stop when that particular condition is true and program is running on debug mode.

 

2) Use Exception breakpoint

How many times you have frustrated with a NullPointerException and you don't know the source from where the exception is coming. Exception breakpoints are just made for such situation. Both Eclipse and Netbeans allows you to setup Exception breakpoint. You can setup Exception breakpoint based on java exception like NullPointerException or ArrayIndexOutOfBoundException. You can setup Exception breakpoint from breakpoint window and your program will stop when you start it on debug mode and exception occurs.

 

3) Step over, Step Into

These are simply great debugging options available in any Java IDE, extremely useful if you are debugging multi-threaded application and want to navigate step by step.

 

4) Stopping for a particular Thread

This is my own custom made java debugging tips which I made using conditional breakpoints. since most of my projects are multi-threaded java programs and I want only a particular thread to stop on a particular line, for doing that I setup a conditional breakpoint on that line and put Thread.currentThread().getName().equals("TestingThread") and it works fantastically.

 

5) Inspect and Watch

These are two menu options which I use to see the value of expression during debugging java program. I just select the statement, right click and inspect and it will show you the value of that statement at debugging time. You can also put watch on that and that condition and its value will appear on watch window.

 

6) Suspending and resuming thread

You can suspend and resume any thread while debugging java program from debug window. Just right click on any thread and select either suspends or resume. This is also very useful while debugging multi-threading program and simulating race conditions.

 

7) Using logical structure

Logical structure option is very useful for examining contents inside java collection classes like java hasmap or Java Arraylist during java debugging. Logical view will show the contents like key and value of hashmap instead of showing full details of hashmap which we may not be interested, you can enable and disable logical view from variables window.

 

8) Step filtering

When we do Step Into on process debugging java program control goes form one class to other and it eventually go to JDK classes like System or String. Some time we just to remain in our application and don't want to navigate into JDK System classes in that case Step filtering is great you can just filter out JDK class from Step into. You can setup step filtering from preferences àJavaàDebugàStep Filtering and enable and disable it from Debug window.

 

9) Copy Stack

While debugging java program if you want to copy the stack of a thread which hit the breakpoint and suspended you do so by "Copy Stack" option. Just right click on Thread on Debug Window and select "Copy Stack".

 

10) Last tip is use java debugging as last option and not the first option because it’s very time consuming, especially remote java debugging which takes a lot of time if network latency is very high between local and remote host. Try to identify problem by looking at code it would be very handy and quick.

 

Read more: http://javarevisited.blogspot.com/2011/07/java-debugging-tutorial-example-tips.html#ixzz2UjfGhnT1

分享到:
评论

相关推荐

    java script 调试工具 脚本控制台

    WEB 开发人员的得力工具,只需要在网页中嵌入一个js文件,即使在模式对话框中,也一样方便在线查看网页源码,javascript变量,在页面上执行自定义脚本,即写即运行,不影响被调试页面的外观。 主要功能: 变量 ...

    Better,Faster,Lighter Java mobi格式

    Better, Faster, Lighter Java shows you howthey can help you create enterprise applications that are easier tomaintain, write, and debug, and are ultimately much faster. Writtenfor intermediate to ...

    Java反编译Jad大全:jad.1.5.8+net.sf.jadclipse_3.3.0+配置方法

    Eclipse中的插件安装可以参考:Eclipse使用技巧(三)Eclipse中插件的安装 方法1、直接将jadclipse_x.x.x.jar(x.x.x.代表版本号)复制到%ECLIPSE_HOME%\plugins目录下。 方法2、使用link方式安装,建立D:\...

    EditPlus 2整理信箱的工具

    【14】工具集成——编译器集成例子(Java、Borland C++、Visual C++、Inno Setup、nsis、C#) 【15】工具集成——让Editplus调试PHP程序----------------------avenger,aukw@CCF 【16】工具集成——打造 PHP 调试...

    新东方java笔试题-AOC2020:AOC2020

    它们(大部分)已经过清理,并且都是使用我自己的工作流工具在 Java 中生成的(加入了一些技巧)。 比赛已经结束,我已经完成(至少是最低限度的)每个谜题,还有一些工作要做。 我需要完成我的拼图写作并完成清理我...

    阿里云javasdk源码-FlutterDemo:颤振演示

    阿里云java sdk源码 FlutterDemo :card_index: 内容大纲: 项目介绍 配置开发环境 安装开发工具 Debug 技巧 三方库使用与发布 iOS 混编开发(Swift、OC) Demo 演示 :rolled-up_newspaper: 项目介绍 官方示例 目前来...

    Eclipse整合开发工具-基础篇

    2.8功能表和工具列 27 2.8.1功能表 28 2.8.2圖示和按鈕 43 2.9視景 48 2.9.1新視景 48 2.9.2新視窗 50 2.9.3儲存視景 51 2.9.4配置視景 53 2.10作業和標記 54 2.10.1不相關的作業 55 2.10.2相關的作業 55 2.10.3開啟...

    Eclipse – 整合开发工具

    要訣和技巧(Tips and Tricks) 266 7.1編輯程式檔(Editing Source) 266 7.2搜尋(Searching) 271 7.3程式碼導覽和讀取(Code navigation and reading) 273 7.4 Java視圖(Java views) 277 7.5...

    editplus 代码编辑器html c++ jsp css

    【14】工具集成——编译器集成例子(Java、Borland C++、Visual C++、Inno Setup、nsis、C#) 【15】工具集成——让Editplus调试PHP程序———————-avenger,aukw 【16】工具集成——打造 PHP 调试环境(二)——...

    Editplus 3[1].0

    【14】工具集成——编译器集成例子(Java、Borland C++、Visual C++、Inno Setup、nsis、C#) 【15】工具集成——让Editplus调试PHP程序----------------------avenger,aukw@CCF 【16】工具集成——打造 PHP 调试...

    Eclipse完全攻略

    《Eclipse – 整合開發工具》 详细介绍了Eclipse的背景,菜单栏各项的使用方法,各种视图,Preferences的设定,Eclipse下java的开发,debug,重构,以及各种实用技巧等,希望对Eclipse的使用者带来帮助。...

    android logcat使用

    Android SDK下, 如何在程序中...使用技巧: 1.使用logcat &在后台运行 2.使用-d得到所有log 3.使用-f或者重定向(>和>>)输出到文件 4.使用-s设置过滤器,得到想要的log。 当然,最重要的还是在程序中加入恰当的log

    Toad 使用快速入门

    Toad 使用快速入门 目录 一.Toad功能综述 二.系统需求 三.安装指南 四.快速入门 1. Schema browser的用法简介 2. SQL Editor的使用介绍 3. Procedure Editor的用法介绍 4. 如何进行PLSQL的debug 5. 如何...

    Eclipse 中文教程

    2.8菜单和工具列 20 2.8.1菜单 20 2.8.2图标和按钮 31 2.9视景 36 2.9.1新视景 36 2.9.2新窗口 37 2.9.3储存视景 38 2.9.4配置视景 40 2.10作业和标记 41 2.10.1不相关的作业 41 2.10.2相关的作业 42 2.10.3开启档案...

    eclipse 中文版教程

    28 菜单和工具列 28 281 菜单 29 282 图标和按钮 44 29 视景 49 291 新视景 49 292 新窗口 51 293 储存视景 52 294 配置视景 54 210 作业和标记 55 2101 不相关的作业 56 2102 相关的作业 56 2103 开启...

    Eclipse中文教程文档

    2.8功能表和工具列 27 2.8.1功能表 28 2.8.2圖示和按鈕 43 2.9視景 48 2.9.1新視景 48 2.9.2新視窗 50 2.9.3儲存視景 51 2.9.4配置視景 53 2.10作業和標記 54 2.10.1不相關的作業 55 2.10.2相關的作業 55 2.10.3開啟...

    Visual C++ 2010入门经典(第5版)--源代码及课后练习答案

     Ivor Horton是撰著Java、C和C++编程语言图书的杰出作家之一。大家一致认为,他的著作独具风格,无论是编程新手,还是经验丰富的编程人员,都很容易理解其内容。在个人实践中,Ivor Horton也是一名系统顾问。他从事...

    Eclipse从入门到精通.rar

    7.要诀和技巧(Tips and Tricks) ....................... 267 7.1 编辑程序文件(Editing Source)................. 267 Eclipse 中文教程.doc 第 7 頁,共 288 頁 7.2 搜寻(Searching)...... 272 7.3 程序代码导...

    MYSQL

    10.6 选择一种表类型 10.6.1 静态(定长)表的特点 10.6.2 动态表的特点 10.6.3 压缩表的特点 10.6.4 内存(In-memory table)表的特点 10.7 其他优化技巧 10.8 使用你自己的基准测试 ...

Global site tag (gtag.js) - Google Analytics