Script Analytics

2012/12/22

How to debug a remote Java application

It is not worth an entry but... I always forgot how to remotely debug a jvm :

Firstly, jvm options :
-Xdebug : Enables debugging support in the VM
-Xrunjdwp:<options> : Loads in-process debugging libraries and specifies the kind of connection to be made (Xrunjdwp parameters)
I use -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000



Secondly, debug the remote application :
  • With Eclipse :
Go to Run -> Debug Configurations and create a new Remote Java Application. 
Set the project you will debug in order to have source biding during debug and specify remote server connection configuration : host and debug port specified in -Xrunjdwp options.

Now, once your application is started, just click Debug and your IDE will be linked with the remote jvm.

Launch jdb (found in your JAVA_HOME/bin) with remote jvm connection parameters :
jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=8000

If you want more informations on jdb, there is a great article by Herong Yang.

No comments:

Post a Comment