eclipse 远程调试

 

远程调试Java应用

 http://blog.sina.com.cn/s/blog_6e2d53050101j9wy.html

 

http://www.cnblogs.com/HighFun/archive/2013/06/06/3120256.html

 

 

在java-config 中增加如下配置

debug-enabled="true" debug-options="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9009"


其中,suspend的用途:

如果为N,则表示java应用可以先启动运行,然后远程debug可以随时再连接。启动glassfish的日志如下

复制代码
D:\glassfish-3.1.2.2\glassfish3\glassfish\bin>asadmin start-domain
Waiting for domain1 to start ...
Successfully started the domain : domain1
domain  Location: D:\glassfish-3.1.2.2\glassfish3\glassfish\domains\domain1
Log File: D:\glassfish-3.1.2.2\glassfish3\glassfish\domains\domain1\logs\server.
log
Admin Port: 4848
Debugging is enabled.  The debugging port is: 9009
Command start-domain executed successfully.

D:\glassfish-3.1.2.2\glassfish3\glassfish\bin>
复制代码


如果为Y,则java应用会先挂起,应用无法访问,一直等待远程debug的连接,启动glassfish的日志如下:

D:\glassfish-3.1.2.2\glassfish3\glassfish\bin>asadmin start-domain
Debugging is enabled and the server is suspended.  Please attach to the debuggin
g port at: 9009
Waiting for domain1 to start ......


然后在Eclipse 中开启远程debug,可以调试,并且应用也可以访问,glassfish追加日志如下:

复制代码
D:\glassfish-3.1.2.2\glassfish3\glassfish\bin>asadmin start-domain
Debugging is enabled and the server is suspended.  Please attach to the debuggin
g port at: 9009
Waiting for domain1 to start ............................
Successfully started the domain : domain1
domain  Location: D:\glassfish-3.1.2.2\glassfish3\glassfish\domains\domain1
Log File: D:\glassfish-3.1.2.2\glassfish3\glassfish\domains\domain1\logs\server.
log
Admin Port: 4848
Debugging is enabled.  The debugging port is: 9009
Command start-domain executed successfully.

D:\glassfish-3.1.2.2\glassfish3\glassfish\bin>
复制代码

 

 在Eclipse 配置 remote debug 时,  注意下面的单选框。如果选了,在remote debug 时,如果点击“Terminal”, 会导致java应用的停止,所以此处不要勾选

 

posted on   迷茫中寻找方向  阅读(421)  评论(0编辑  收藏  举报

编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示