-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009If the java process runs and terminates itself, change suspend=y, so you can have a chance to attach the remote debugger.
To add the same debug options to ant build.xml java task:
<target name="run">Or, with the newer -agentlib option:
<java fork="on"
failonerror="true"
classpath="xxx"
classname="xxx">
<jvmarg line="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9009" />
<arg line="--arg1 arg2 --arg3 arg4"/>
</java>
</target>
<target name="test" depends="compile">Note:
<junit printsummary="yes" haltonerror="no" haltonfailure="no" fork="true">
<formatter type="plain" usefile="false"/>
<formatter type="xml"/>
<test name="FooBeanTest"
todir="xxx"/>
<jvmarg line="-agentlib:jdwp=transport=dt_socket,address=localhost:9009,server=y,suspend=y" />
<classpath>
<path refid="test.compile.classpath"/>
<path refid="javaee.classpath"/>
<pathelement path="${build.dir}"/>
<pathelement path="${junit.jar}"/>
</classpath>
</junit>
</target>
<arg>
and <jvmarg>
take either line
or value
attribute, but value
attributes are treated as one single argument that may contain spaces. So in our case line
attribute is used to specify multiple arguments separated by spaces. If value
attribute was used instead of line
attribute, the debug options will not take effect.