Enable the remote debug mode of JVM and add the following parameters when starting JVM:
// Non-blocking mode. After JVM is started, attach the JVM to the server at any time.-xdebug-xnoagent-xrunjdwp: Transport = dt_socket, address = 11312, Server = Y, suspend = N // block Debug. After JVM is started, you need to remotely connect attach to the corresponding port to continue JVM execution. -Xdebug-xnoagent-xrunjdwp: Transport = dt_socket, address = 11312, Server = Y, suspend = y
Article 2 is particularly suitable for debugging class initializationProgramModule.
In eclipse, the bug items include debug configurations... selected. Select Remove Java application to create
Project is the Java source code file project that you want to remotely debug. Host is the name or IP address of the server. Port is the preceding address item 11312. Set the connection type to standard. Click debug.
If a connection error occurs after debug. 1. Check whether the server or service has been started. 2. Check whether the configuration is correct. 3. Check whether the port is occupied by other programs.
If the above detection is complete, the connection still fails. Restart eclipse or restart server to solve the problem.
In addition
-Xnoagent
This option is generally not required in remote debug. It meansDisables VM supportOldjdb. Disable the old Java debug.
The following is a detailed description of various options. From http://docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/jdb.html
| -Xdebug |
Enables debugging support in the VM |
| -Xrunjdwp: Transport = dt_shmem, Server = Y, suspend = N |
Loads in-process debugging libraries and specifies the kind of connection to be made. |
| -Xnoagent |
Disables VM supportOldjdb |
| -Djava. compiler = none |
Disables the JIT compiler. This is required for debugging under the classic VM |