Monday, June 29, 2009

Remote Debugging with JPDA

For developing Java applications, JPDA (Java Platform Debugger Architecture) is an important toolkit for debugging applications that is failing in a deployment environment. This is particularly useful in situations where the deployment environment does not have a development environment and can only be debugged remotely.
To enable remote debugging, the Java application must be compiled with debugging enabled (-g) and must not be obfuscated or optimized. When launching the Java application, include the following argument:
This says that the JVM should listen on the socket transport. Another possibility is to use shared memory as transport (dt_shmem). By default, JVM suspends before the main class loads unless otherwise indicated (suspend=n). In this example, the JVM listens on the specified port (8777) for a debugger to connect before resuming execution. To make the JVM initiate the connection, specify server=n.


Make a duplicate of your application launcher (Launcher). Double-click on the duplicate launcher to modify it. Select Java Invocation to configure it. In the VM Parameters text field, add the JPDA arguments show above.
Make a duplicate of your media file (Media) and include the debuggable launcher.
Run the installer. When the debuggable application launch, it will wait for the debugger to connect. If you launch the debuggable application from the command line, you will see a message indicating that it's waiting on the socket transport at port 8777.


Tomcat startup script ( or startup.bat) has JPDA built in. All you need to do is specify "jpda" when starting Tomcat. By default, it waits on the socket port 8000 until a debugger connects.


In the start WebLogic script, look for JAVA_ARGS and append the JPDA argument shown above. WebLogic will wait for a debugger to connect before proceeding.

Debugging from Eclipse

On the computer where your source code resides and where Eclipse is installed, create a Debugging Configuration. Select the Connection Type and provide the host address and port (e.g., Standard (Socket Attach), localhost and 8777). Click [Debug] to start debugging. The application being debugged will resume. Set a breakpoint somewhere in your source code and watch the remote application stops at your breakpoint.
Other debuggers can be set up similarly.


  1. Peter V. Mikhalenko, Debug Your Java Code with Ease Using JPDA, TechRepublic, 11/30/2006.
  2. Java Platform Debugger Architecture, Sun.

No comments:

Post a Comment