java遠程調試

要想調試服務器上的java系統,須要加上一些啓動參數:java

eclipse中遠程調試windows

-Xdebug服務器

Enables debugging features.app

-Xrunjdwp:<sub-options>eclipse

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.socket

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.this

transport:鏈接方式,經過socket方式,或者內存共享方式(限定windows)spa

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

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,進入了調試模式。操做以下圖:

相關文章
相關標籤/搜索