java远程调试

要想调试服务器上的java系统,需要加上一些启动参数:

eclipse中远程调试

-Xdebug

Enables debugging features.

-Xrunjdwp:<sub-options>

Loads the implementation of JDWP in the target VM. It uses a transport and the JDWP protocol to communicate with a separate debugger application. Specific suboptions are described below.

Starting from Java V5, you can use the -agentlib:jdwp option, instead of -Xdebug and -Xrunjdwp. But if you have to connect to the VM prior to V5, -Xdebug and -Xrunjdwp will be the only choice. Following are brief descriptions of the -Xrunjdwp suboptions.

transport:连接方式,通过socket方式,或者内存共享方式(限定windows)

Generally, socket transport is used. But shared-memory transport can also be used on the Windows platform, if available.

server:y表示被调试的服务器,n表示调试的客户端。

If the value is y, the target application listens for a debugger application to attach. Otherwise, it attaches to a debugger application at the specified address.

address:当server=y是,表示服务器监听的端口。当server=n时,表示本机是调试客户端,address表示远程的服务器地址:端口。

This is the transport address for the connection. If the server is n, attempt to attach to a debugger application at this address. Otherwise, listen for a connection at this port.

suspend:y表示调试客户端没连接上服务器就一直挂起。n则不受影响。

If the value is y, the target VM will be suspended until the debugger application connects.

例如:服务端

java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n
-jar target/myproject-0.0.1-SNAPSHOT.jar

调试客户端:

在eclipse里面点击 Run > Debug Configurations, and double-click the Remote Java Application in the Eclipse menu. 指定项目源码、服务器ip和端口,点击右下角的debug,进入了调试模式。操作如下图:

 

 

转载于:https://my.oschina.net/u/2007041/blog/735811

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值