Java applications can be debugged by attaching its source to a remotely IDE following a client-server approach. The running Java application is considered as server and the IDE with source attached is considered as client.
Server (Java application)
The application to be debugged should be started with the following JVM argument for Java 5.0 and beyond.
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
The debugger listens to the port 8000.
Executing java -agentlib:jdwp=help on the command prompt shows the help and list of options.
For pre Java 5.0, the server should be started with
-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000, suspend=n
Client (Eclipse IDE)
Server (Java application)
The application to be debugged should be started with the following JVM argument for Java 5.0 and beyond.
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
The debugger listens to the port 8000.
Executing java -agentlib:jdwp=help on the command prompt shows the help and list of options.
For pre Java 5.0, the server should be started with
-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000, suspend=n
Client (Eclipse IDE)
- Click the Debug Configurations in the Debug button menu.
- In Debug Configurations window, right click Remote Java Application and click New.
- Give an appropriate name for the remote debug configuration.
- The Connection Type should be Standard (Socket Attach)
- Enter the Host on which the Java application is running.
- Enter the Port which was used as addresss=
while starting the Java application. - In the Source tab select a project or source jar.
- Click Apply to save the settings.
- Set appropriate break points in the source and start debugging by clicking on Debug in the Debug Configurations window.
No comments:
Post a Comment