要想调试服务器上的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,进入了调试模式。操做以下图: