Debugging any Java Application

Post Java 5 update :(the old one still works but is spread in 2 JVM options, versus one)

As long as you’re using a java application (ie an application calling your JVM), you can enable the debug mode with these parameters :

-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y

So for example, if you want to debug an ant launch (launched via « ant -f myBuild.xml » for example), you simply have to set ANT_OPTS; on windows :

set ANT_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y

Another example, with JBoss :

set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y

and then you can debug your launch with Eclipse, for example, creating a new debug configuration (remote java application on port 8787) !
Option : you can choose whether or not the application should wait for your debugger setting suspend to y or n.

Une réflexion au sujet de « Debugging any Java Application »

  1. Update ! Make sure you use the same version of the JVM on both sides !(eclipse and the remote application launched in debug mode); for example if your application is started with a 64 bit JVM, your eclipse must use a 64 bits JVM also !

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée.

Le temps imparti est dépassé. Merci de saisir de nouveau le CAPTCHA.