java 的远程调试
2007-03-30 14:31
357 查看
jdb是java的调试工具,它不仅提供了本地调试,还能远程调试。在自己的电脑上可以调试在生产环境中的java程序,这对于在生产环境中出现的问题,一时找不出问题。在测试环境或者模拟环境又重现不了,这时候就可以用jdb的远程调试了。
jdb和 gnu 的c/c++调试工具 gdb,命令差不多, 基本上都一样。 熟悉在linux开发的c开发人员 ,很容易就能够掌握jdb。可以在http://java.sun.com/javase/6/docs/technotes/guides/jpda/找到它的详细介绍。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class RemoteDebug extends java.lang.Thread
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public static void main(String[] argv)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
while ( true )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.out.println("Hello");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
try
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
java.lang.Thread.sleep(1000);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
catch(Exception e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.out.println(e.toString());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
1,编译:javac -g src.java 最好加上-g选项
2,运行:java -agentlib:jdwp=transport=dt_socket,server=y,address=localhost:7000,suspend=n ClassName
Listening for transport dt_socket at address: 7000
3,调试L:jdb -connect com.sun.jdi.SocketAttach:hostname=192.168.1.230,port=7000
设置 未捕捉到 java.lang.Throwable
设置延迟的 未捕捉到 java.lang.Throwable
正在初始化 jdb...
>
接下来就和调试本地程序一样了,
stop at
stop in设置断点
print查看变量的值
......
jdb和 gnu 的c/c++调试工具 gdb,命令差不多, 基本上都一样。 熟悉在linux开发的c开发人员 ,很容易就能够掌握jdb。可以在http://java.sun.com/javase/6/docs/technotes/guides/jpda/找到它的详细介绍。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
class RemoteDebug extends java.lang.Thread
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public static void main(String[] argv)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
while ( true )
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.out.println("Hello");
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
try
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
java.lang.Thread.sleep(1000);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
catch(Exception e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
System.out.println(e.toString());
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
1,编译:javac -g src.java 最好加上-g选项
2,运行:java -agentlib:jdwp=transport=dt_socket,server=y,address=localhost:7000,suspend=n ClassName
Listening for transport dt_socket at address: 7000
3,调试L:jdb -connect com.sun.jdi.SocketAttach:hostname=192.168.1.230,port=7000
设置 未捕捉到 java.lang.Throwable
设置延迟的 未捕捉到 java.lang.Throwable
正在初始化 jdb...
>
接下来就和调试本地程序一样了,
stop at
stop in设置断点
print查看变量的值
......
相关文章推荐
- eclipse下通过jetty远程调试Java应用
- 远程调试Java程序,远程Debug
- Java Remote Debug(idea远程调试)
- Eclipse远程调试Java程序
- linux下的java远程调试jpda+tomcat
- Java_tomcat配置远程调试
- Eclipse快速入门:远程调试Java应用
- 使用 Eclipse 远程调试 Java 应用程序
- java 远程调试配置linux下的tomcat服务器
- java远程调试服务器的工程配置
- 如何对生产环境的JAVA应用进行远程调试
- java远程执行调试类
- 如何实现远程调试java代码
- java 远程调试butterfly
- Java远程debug调试
- Java远程调试
- Eclipse远程调试Java
- java 远程调试
- JAVA远程调试设置
- java远程调试、监控虚拟机