How to remote debug your java application

On the server (the remote location)

  1. Add the following jvm arguments to your run.sh script
    1. -Xdebug
    2. -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
      1. address=8000 can be configured to any available port on the server
      2. suspend=n means that the application will run normally, even after you connect to it. After connecting, you will be able to suspend threads or insert breakpoints just as you would expect with local debugging
  2. Bounce the application

On the client side (using Eclipse)

  1. From the main Eclipse context window (File, Edit, etc…) choose Run -> Debug Configurations
  2. Locate "Remote Java Application" in the left pane
  3. Right click and choose "New"
  4. Name your configuration something you will remember. This is what you will run.
  5. Under the "Project" section, browse your local workspace to find the source that corresponds to the remote application
  6. Under "Connection Type", choose "Standard (Socket Attach)"
  7. Fill in the "Host" and "Port" boxes with remote host and the port you specified in the "address=xxxx" section above
  8. Click Apply or Debug to save your configuration.
  9. To see active threads, launch your "Debug" view. In most standard installations, that view is a part of the Debug perspective.
  10. You can now suspend processes, place breakpoints, step through code, etc.

NOTE: When you are done, you probably want to right click the project in the "Debug" view and choose "Disconnect". If you choose "Terminate", or just use the red square like you probably normally do, you will kill the process out on the server.