eclipse Remote debugging of a Java application


Example

n order to debug a remote Java application, it should be launched with some extra arguments to instruct the JVM to execute it in debug mode. This is done as follows:

java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 -jar sampleApp.jar

The above command tells the JVM to start the application sampleApp.jar while having a server socket listening at port 8000 for a debugger to attach to it. The suspend argument tells whether you want the JVM to wait until a debugger attaches to the port number before the application effectively runs.

After launching the remote application with the above parameters, the next step is attach your Eclipse debugger to the remote application. This is done as follows:

  1. Go to Run > Debug Configurations...

  2. In the Debug Configurations dialog (see figure below), select the Remote Java Application section and click New launch configuration action.

  3. Give your debug configuration a name, then select the project that contains the code of your remote application. Set the hostname or IP address of the remote machine and the port to which the debugger should attach.

  4. Click Debug. The Eclipse debugger will now attempt to attach to the remote application and suspend at breakpoints set in the source code.

enter image description here