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.2glassfish3glassfishin>asadmin start-domain
Waiting for domain1 to start ...
Successfully started the domain : domain1
domain  Location: D:glassfish-3.1.2.2glassfish3glassfishdomainsdomain1
Log File: D:glassfish-3.1.2.2glassfish3glassfishdomainsdomain1logsserver.
log
Admin Port: 4848
Debugging is enabled.  The debugging port is: 9009
Command start-domain executed successfully.

D:glassfish-3.1.2.2glassfish3glassfishin>


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

D:glassfish-3.1.2.2glassfish3glassfishin>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.2glassfish3glassfishin>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.2glassfish3glassfishdomainsdomain1
Log File: D:glassfish-3.1.2.2glassfish3glassfishdomainsdomain1logsserver.
log
Admin Port: 4848
Debugging is enabled.  The debugging port is: 9009
Command start-domain executed successfully.

D:glassfish-3.1.2.2glassfish3glassfishin>

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

原文地址:https://www.cnblogs.com/SamuelSun/p/5912528.html