1 March 2013

How to remotely debug your java application on a Linux/Mac?


What you need

  • Eclipse
  • Tomcat
  • Terminal

What you have to do

Setting up environment

First of all you have to add the following lines to your .bash_profile (or .bashrc? what do you think? in mac .bash_profile, in linux .bashrc)

  • export JPDA_ADDRESS=8000
  • export JPDA_TRANSPORT=dt_socket
  • (You can change the port 8000 to the port of your choice). 

Debugging using remote

Then, you have to add a new remote java application debug environment to your Eclipse environment. You can follow instructions here (Make sure to use the same port you have exported).
The last step would be ro run Tomcat server with the jdpa start option, something like:

  • bin/catalina.sh jpda start

Now, the only thing remains is to put a breakpoint in your application (in your java source code). When the code gets to the point that you have put breakpoint it will stop and will handle execution to the eclipse environment (not completely true though). Just make sure you have deployed the same application on the server that you are seeing its code.

Note: JPDA stands for Java Platform Debugger Architecture

No comments:

Post a Comment