- 浏览: 978121 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
运乃强谦:
老哥,你确定这个wsdl 地址 可以访问?
[CXF] Server与Client实现方式五:HTTPS -
wangyudong:
由CXF实现的微服务需要有比较好的工具去测试RESTful A ...
[CXF] Server与Client实现方式四:JMS -
dengmiao:
JAXB学习三 (验证) -
panamera:
你好。可以提供maven pom配置是怎么配置的?不知道你使用 ...
[CXF] Server与Client实现方式四:JMS -
u010221220:
请问楼主一二三部分的代码都应该放在哪个函数体中。
使用JDI监听Java程序运行
Java里提供了非常强大、易用的调试工具和调试接口,可以方便的用来以调试的方式进行java应用,并且可以很容易的连接上这些调试。
这里简单介绍一下如何在指定的端口上以调试的方式启动一个程序,并且在另外一个命令中连接上这个程序进行调试。
整个Java平台调试框架(JavaTM Platform Debugger Architecture (JPDA))由三个部分组件:
- The Java Virtual Machine Tools Interface (JVM TI) defines the services a VM must provide for debugging (JVM TI is a replacement for the Java Virtual Machine Debug Interface (JVMDI) which has been removed). http://docs.oracle.com/javase/6/docs/technotes/guides/jpda/architecture.html#jvmti
- The Java Debug Wire Protocol (JDWP) defines the format of information and requests transferred between the process being debugged and the debugger front end, which implements the Java Debug Interface (JDI). http://docs.oracle.com/javase/6/docs/technotes/guides/jpda/architecture.html#jdwp
- The Java Debug Interface (JDI) defines information and requests at the user code level. http://docs.oracle.com/javase/6/docs/technotes/guides/jpda/architecture.html#jdi
不过我不要是关心这个,我只介绍一下怎么使用Java调试工具:JDB (Java Debugger).
首先需要指定程序以调试的方式启动,命令行如下:
javaw.exe -Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=y|n,address=[host:]<port_number> -Dfile.encoding=<encoding> -classpath <classpath> <main_class>
上面的意思是说:
在端口<port_number>上监听socket连接,并且在main类加载之前挂起虚拟机。一旦调试程序连接上了,再发出一个JDWP的命令唤醒虚拟机
更多的命令行指导,请参考:http://docs.oracle.com/javase/6/docs/technotes/guides/jpda/conninv.html
运行上面的命令,如果成功,会在console上打印一条类似如下消息:
Listening for transport dt_socket at address: 3556
表明程序启动成功。
下面就可以用JDB去尝试连接调试了,命令行为:
jdb -sourcepath <source_dir1:source_dir2:...> -connect com.sun.jdi.SocketAttach:hostname=<host>,port=<port_number>
更多的,请参考:http://docs.oracle.com/javase/1.3/docs/tooldocs/solaris/jdb.html。
如果启动成功,则可以看到类似下面的消息:
Set uncaught java.lang.Throwable Set deferred uncaught java.lang.Throwable Initializing jdb ... > VM Started: No frames on the current call stack main[1]
程序现在在主线程等待进一步的指示命令。
要查看帮助可以使用命令:help。 例如:
main[1] help ** command list ** connectors -- list available connectors and transports in this VM run [class [args]] -- start execution of application's main class threads [threadgroup] -- list threads thread <thread id> -- set default thread suspend [thread id(s)] -- suspend threads (default: all) resume [thread id(s)] -- resume threads (default: all) where [<thread id> | all] -- dump a thread's stack wherei [<thread id> | all]-- dump a thread's stack, with pc info up [n frames] -- move up a thread's stack down [n frames] -- move down a thread's stack kill <thread id> <expr> -- kill a thread with the given exception object interrupt <thread id> -- interrupt a thread print <expr> -- print value of expression dump <expr> -- print all object information eval <expr> -- evaluate expression (same as print) set <lvalue> = <expr> -- assign new value to field/variable/array element locals -- print all local variables in current stack frame classes -- list currently known classes class <class id> -- show details of named class methods <class id> -- list a class's methods fields <class id> -- list a class's fields threadgroups -- list threadgroups threadgroup <name> -- set current threadgroup stop in <class id>.<method>[(argument_type,...)] -- set a breakpoint in a method stop at <class id>:<line> -- set a breakpoint at a line clear <class id>.<method>[(argument_type,...)] -- clear a breakpoint in a method clear <class id>:<line> -- clear a breakpoint at a line clear -- list breakpoints catch [uncaught|caught|all] <class id>|<class pattern> -- break when specified exception occurs ignore [uncaught|caught|all] <class id>|<class pattern> -- cancel 'catch' for the specified exception watch [access|all] <class id>.<field name> -- watch access/modifications to a field unwatch [access|all] <class id>.<field name> -- discontinue watching access/modifications to a field trace [go] methods [thread] -- trace method entries and exits. -- All threads are suspended unless 'go' is specified trace [go] method exit | exits [thread] -- trace the current method's exit, or all methods' exits -- All threads are suspended unless 'go' is specified untrace [methods] -- stop tracing method entrys and/or exits step -- execute current line step up -- execute until the current method returns to its caller stepi -- execute current instruction next -- step one line (step OVER calls) cont -- continue execution from breakpoint list [line number|method] -- print source code use (or sourcepath) [source file path] -- display or change the source path exclude [<class pattern>, ... | "none"] -- do not report step or method events for specified classes classpath -- print classpath info from target VM monitor <command> -- execute command each time the program stops monitor -- list monitors unmonitor <monitor#> -- delete a monitor read <filename> -- read and execute a command file lock <expr> -- print lock info for an object threadlocks [thread id] -- print lock info for a thread pop -- pop the stack through and including the current frame reenter -- same as pop, but current frame is reentered redefine <class id> <class file name> -- redefine the code for a class disablegc <expr> -- prevent garbage collection of an object enablegc <expr> -- permit garbage collection of an object !! -- repeat last command <n> <command> -- repeat command n times # <command> -- discard (no-op) help (or ?) -- list commands version -- print version information exit (or quit) -- exit debugger <class id>: a full class name with package qualifiers <class pattern>: a class name with a leading or trailing wildcard ('*') <thread id>: thread number as reported in the 'threads' command <expr>: a Java(tm) Programming Language expression. Most common syntax is supported. Startup commands can be placed in either "jdb.ini" or ".jdbrc" in user.home or user.dir main[1]
例如输入:step,程序运行到下一步。
发表评论
-
自定义Spring MVC中的数据绑定
2015-02-01 18:27 1436默认情况下,spring mvc的数据映射的实现是自动查找请 ... -
Java单例(Singleton)
2014-05-22 11:40 1859【译自:http://www.journaldev.com ... -
Java函数式编程学习二
2014-06-05 10:58 2626上一节里,介绍了一个函数接口: java.uti ... -
Java函数式编程学习一
2014-05-07 22:02 7304一、缺省方法 首先看一段用Java 8写的代码: ... -
快速排序的几种实现
2014-05-06 23:13 1625快速排序是最经典的 ... -
计算Fibonacci数列
2014-05-04 15:37 1605Fibonacci数列的定义如 ... -
(转)Java函数式编程系列文章
2014-04-11 16:52 706转载: Java函数式编程(一) Java函数式编程( ... -
Java中的动态代理
2014-04-02 15:11 2311在使用CXF的时候,尤其是创建针对REST或SOAP服务的 ... -
Java 7中的Path
2014-04-01 17:33 0package test; public ... -
HashMap对HashTable和ArrayList对Vector
2014-03-26 14:16 817有人面试总喜欢问比 ... -
Java国际化:BreakIterator
2014-03-21 11:51 2932【译自:http://tutorials.jenkov.c ... -
Java中使用StreamTokenizer
2014-03-21 09:44 3262按照Javadoc里的描述:StreamTokenizer ... -
Java中枚举的用法
2014-03-19 15:31 2755Java 5里新引用了枚举类型,这篇文章简单介绍一下它的基 ... -
Java线程类三
2014-03-06 11:18 1114一、Callable 最早创建线程要么是通过实现Runn ... -
Java线程类二
2014-03-05 14:21 1156一、java.util.concurrent.Exchan ... -
Java线程类一
2014-03-04 17:25 914一、java.util.concurrent.CountD ... -
基于Java的Dropbox文件操作
2014-01-22 11:15 4285Dropbox提供了基于各种类型的API和应用类型的开发工 ... -
使用特殊字符控制Console输出
2013-11-28 10:39 1029如果要在console上打印 Hello + 1到10,最简 ... -
控制JAXB的输入输出
2013-11-27 16:06 4063上一节介绍了如何在解析模型的时候构建模型之间的父子链,其实 ... -
JAXB中怎么构建对父对象的链接
2013-11-27 11:17 3533还是以在第一节介绍JAXB的schema为例: < ...
相关推荐
Mac 在创建虚拟串口上没有 Windows 方便,windows 有 VSPD 用起来非常方便,但是 Mac 就没有那么方便了,本 java 程序基于 socat 和 jdk8,可以自动创建一对虚拟串口,以供 RXTX comm 调试使用
*******大 学 学 生 实 验 报 告 实验课程名称 J2EE及JAVA程序设计 开课实验室 DS1501 学 院 软件学院 年级 2012 专业班 2班 学 生 姓 名 学 号 开 课 时 间 2013 至 2014 学年第 2 学期 "总 成 绩 " " "教师签名 " ...
最后需要说的是笔者的调试上面程序的环境:WIN2000 , JDK1.3,MS SQLSERVER编辑软件:EDITPLUS 2.01a(这最后的东西可不是废话,虽然早就了一些专业的JAVA开发工具,但是笔者建议JAVA初学者使用文本软件开发JAVA程序)...
执照GNU GPL v2.0用法以下步骤可用于创建自定义调试器应用程序: 实现一个EventRequestor类,该类请求将由调试器处理的特定JDI事件实现一个EventVisitor类,该类描述如何处理在步骤1中启用的JDI事件使用...
1.3.3 Java程序的运行 ............................................................................................10 1.3.4 Java程序的调试 .............................................................
运行Java程序,还应该在PATH环境变量中增加%JAVA_HOME%/bin。其中JAVA_HOME代表 JDK(不是JRE)的安装路径。 如何安装上面工具,请参考本书的第1章。 (2) 安装MySQL 5.5或更高版本,安装MySQL时选择GBK编码方式...
本书内容精练、重点突出、实例丰富,是Java程序开发人员必备的参考书,同时也可作为高等院校计算机及相关专业的教材。 图书目录 第1章 初识MyEclipse 1 1.1 MyEclipse简介 1 1.2 MyEclipse的安装 1 1.2.1 JDK的...
可以通过控制台输出、日志文件等方式来监控和调试应用程序的运行状态。 注意事项: 在部署Java应用程序时,需要注意版本和兼容性,防止不同版本的Java环境、类库或框架之间产生冲突和错误。 在配置服务器时,需要...
本示例已调试通过,在Java程序里连接Mysql数据库,通过更改配置文件,可用不同角色连不同数据库,本示例是连的mysql,同样,通过更改配置文件,可连Sql Server、Oracle,内附详细说明,机器环境变量的设置、mysql的角色的...
运行Java程序,还应该在PATH环境变量中增加%JAVA_HOME%/bin。其中JAVA_HOME代表 JDK(不是JRE)的安装路径。 如何安装上面工具,请参考本书的第1章。 (2) 安装MySQL 5.5或更高版本,安装MySQL时选择GBK编码方式...
一、课程设计目的: 1. 学会Java程序开发的环境搭建与配置,并在实际运用中学习和掌握Java程序开发的全过程。 2. 进一步熟悉掌握Java程序设计语言的基础内容,如用户图形界面设计、Java多线程编程、Applet程序...
在Visual J++中,用户可以创建、修改、编译、运行、调试和封装应用程序,所有这些操作都在单一的环境中进行。 Visual j++6.0介绍Java的Windows基础类(WFC),这个新的应用程序框架访问Microsoft Windows API,允许...
****大 学 学 生 实 验 报 告 实验课程名称 J2EE及JAVA程序设计 开课实验室 DS1501 学 院 软件学院 年级 2012 专业班 1 班 学 生 姓 名 学 号 开 课 时 间 2013 至 2014 学年第 2 学期 "总 成 绩 " " "教师签名 " " ...
程序在运行期间所进行的操作被称为“程序行为”(Action),一般泛指程序进行的相对表现较明显的操作,例如创建读写文件、访问注册表、连接网络等,而在这些操作之外做的程序内部运算、判断、逻辑等操作并不是我们...
5 六、调试过程 5 七、实习小结 5 八、参考资料 6 一、实习题目 学生信息管理系统的设计与开发 二、实习目的 1、社会需求 一直以来学生的成绩管理是学校工作中的一项重要内容,随着办学规模的扩大和招生 人数的增加...
第1章Java程序设计概述 1.1 Java程序设计平台 1.2 Java“白皮书”的关键术语 1.2.1简单性 1.2.2面向对象 1.2. 3分布式 1. 2.4健壮性 1. 2.5安仝性 1. 2.6体系结构中立 1.2.7可移植性 1.2.8...
大量调试(破解)在JVM内部运行的Java应用程序。 快速将付费脚本的ClassFiles转储为runescape机器人。 (rofl) 找出应用程序连接到的套接字和URL。 谁他妈的知道,谁玩弄,并采取控制! 如何使用: 下载包含...