- 浏览: 981623 次
- 性别:
- 来自: 北京
-
文章分类
最新评论
-
运乃强谦:
老哥,你确定这个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 1457默认情况下,spring mvc的数据映射的实现是自动查找请 ... -
Java单例(Singleton)
2014-05-22 11:40 1879【译自:http://www.journaldev.com ... -
Java函数式编程学习二
2014-06-05 10:58 2641上一节里,介绍了一个函数接口: java.uti ... -
Java函数式编程学习一
2014-05-07 22:02 7319一、缺省方法 首先看一段用Java 8写的代码: ... -
快速排序的几种实现
2014-05-06 23:13 1647快速排序是最经典的 ... -
计算Fibonacci数列
2014-05-04 15:37 1624Fibonacci数列的定义如 ... -
(转)Java函数式编程系列文章
2014-04-11 16:52 724转载: Java函数式编程(一) Java函数式编程( ... -
Java中的动态代理
2014-04-02 15:11 2333在使用CXF的时候,尤其是创建针对REST或SOAP服务的 ... -
Java 7中的Path
2014-04-01 17:33 0package test; public ... -
HashMap对HashTable和ArrayList对Vector
2014-03-26 14:16 830有人面试总喜欢问比 ... -
Java国际化:BreakIterator
2014-03-21 11:51 2953【译自:http://tutorials.jenkov.c ... -
Java中使用StreamTokenizer
2014-03-21 09:44 3287按照Javadoc里的描述:StreamTokenizer ... -
Java中枚举的用法
2014-03-19 15:31 2776Java 5里新引用了枚举类型,这篇文章简单介绍一下它的基 ... -
Java线程类三
2014-03-06 11:18 1126一、Callable 最早创建线程要么是通过实现Runn ... -
Java线程类二
2014-03-05 14:21 1171一、java.util.concurrent.Exchan ... -
Java线程类一
2014-03-04 17:25 927一、java.util.concurrent.CountD ... -
基于Java的Dropbox文件操作
2014-01-22 11:15 4300Dropbox提供了基于各种类型的API和应用类型的开发工 ... -
使用特殊字符控制Console输出
2013-11-28 10:39 1043如果要在console上打印 Hello + 1到10,最简 ... -
控制JAXB的输入输出
2013-11-27 16:06 4105上一节介绍了如何在解析模型的时候构建模型之间的父子链,其实 ... -
JAXB中怎么构建对父对象的链接
2013-11-27 11:17 3561还是以在第一节介绍JAXB的schema为例: < ...
相关推荐
Java UDP调试工具是一种用于测试和调试UDP(User Datagram Protocol)网络通信的应用程序。UDP是一种无连接的传输协议,常用于需要高效传输且对数据完整性要求不高的场景,如在线视频流、实时游戏等。该工具通常包含...
**Java应用程序调试在JCreator中的配置设置** JCreator是一款流行的Java集成开发环境(IDE),它为程序员提供了便捷的代码编辑、编译、运行以及调试功能。对于初学者和专业开发者而言,理解如何在JCreator中设置...
本篇将详细探讨"JAVA程序与PLC通信——学习使用"这一主题,包括如何使用Java实现与西门子PLC的串口通信,以及如何收发数据。 首先,我们要理解Java语言的优势。Java作为一种跨平台的编程语言,其强大的网络支持和...
在IT行业中,Java程序与PLC(可编程逻辑控制器)之间的通信是一个重要的技术领域,尤其在工业自动化系统中。这个主题涉及到如何利用编程语言与硬件设备进行数据交换,以实现远程控制、监控或数据采集等功能。以下是...
这通常包括确保JVM已配置为接受调试连接,服务器上的防火墙设置允许调试端口的入站连接,以及在本地开发环境中设置相应的远程调试配置。有时,你可能需要使用SSH隧道来安全地连接到远程服务器的调试端口。 最后,...
"jdk-6u17-windows-i586.exe"文件是Java JDK的可执行安装程序,它包含了开发和运行Java应用程序所需的所有组件,包括Java虚拟机(JVM)、编译器(javac)、调试器(jdb)和其他工具。JDK 6是Java的一个重要版本,提供了...
"初学者在调试程序遇到的错误小结" 本文总结了初学者在使用 Eclipse 和 Java 以及 Spring 框架时遇到的常见错误,并提供了相应的解决方案。 一、数据库方面的错误 * 出现 DataAccessException 这样的错误,一般是...
IDEA中的断点调试是Java开发中非常重要的一部分,它可以帮助开发者更好地了解代码的执行过程,Debug程序中的错误,提高开发效率。下面将详细介绍IDEA中的断点调试知识点。 一、常用断点调试快捷键 在IDEA中,Debug...
JDK包含了编译器(javac)和解释器(java),以及其他必要的工具,用于创建、编译和运行Java程序。 标题中的"Example1.java"是你的第一个Java源代码文件。源代码文件通常以.java为扩展名,它包含了用Java语言编写的...
《Java程序设计之网络编程》是一本专注于Java网络编程的教材,它涵盖了网络通信的基础理论以及Java语言在实现网络应用中的各种技术。该资源包括课件和源码,旨在帮助学习者通过实践来深入理解Java网络编程的核心概念...
Java程序设计教程是初学者和进阶者深入理解并掌握Java编程语言的重要资源。这个教程不仅提供了详尽的理论知识,还包含了丰富的实践环节,通过上机调试源码,可以帮助学习者直观地理解代码的运行过程,提升编程技能。...
《Java程序设计实用教程》是叶核亚编著的一本针对初学者和进阶者学习Java编程语言的经典教材。本书深入浅出地介绍了Java的基本概念、语法和编程技巧,旨在帮助读者掌握Java程序设计的核心技能。书中源代码和课后习题...
微信小程序连接Java后端主要涉及的是前后端交互的技术实现,这一过程涵盖了多个技术知识点,包括微信小程序的开发、Java后端API设计与实现、数据传输协议以及认证授权机制等。以下将详细介绍这些方面: 1. **微信小...
在实际开发中,JRE与Java Development Kit(JDK)的区别在于,JDK是用于开发和调试Java程序的完整工具集,它包含了JRE以及编译器(javac)、jar打包工具、文档生成工具等开发工具。而JRE则专注于提供运行Java程序所...
Java程序设计是一门深入探讨如何使用Java编程语言进行软件开发的学科。这门课程的核心是学习如何编写高效、可读性强的代码,并掌握各种编程概念和技术。以下是对标题和描述中涉及的知识点的详细说明: 1. **Java...
《Java程序设计实用教程第三版》是一本专为初学者和有一定基础的程序员设计的Java学习教材。本书全面覆盖了Java编程的基础知识,包括语法、类与对象、接口与继承、异常处理、多线程、网络编程、数据库操作等多个方面...
在Java编程中,获取程序运行环境的信息是一项基本且重要的任务,这有助于开发者了解程序的运行状态,调试问题,以及优化代码。以下是一些关键的知识点,涵盖了如何通过Java源码来获取程序运行环境的信息。 1. **...
远程调试允许开发者在本地IDE上对运行在另一台机器上的应用程序进行调试。这通常通过JVM的远程调试接口实现,即使用标准的Java Debug Wire Protocol (JDWP)。JDWP允许IDE与远程JVM建立连接,进而控制程序执行,设置...
《JAVA程序设计与问题解决》是一本全面介绍Java编程语言的教材,分为基础篇和高级篇,由美国知名计算机科学家Walter Savitch撰写,并有中文翻译版本。这本书旨在帮助读者从零开始学习Java编程,逐步掌握解决问题的...
Java连接MySQL 5.0是Java开发者...这个压缩包提供的实例将展示如何实现上述步骤,帮助初学者快速上手Java与MySQL的连接。通过实际运行和调试这些代码,你可以更好地理解JDBC的工作原理,并学会在自己的项目中使用它们。