Eclipse remote debug (with ant example)

Sometimes you cannot start your program from within eclipse to be able to debug it. Or even worse, you run your application on a remote server where you don’t have the sources or the ability to debug it on that machine. In this case you can use the remote debug capability of the JVM. For this:

1. Start your program with these VM arguments:

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

If your application is started as an Ant task then:

<java dir="${running.dir}" jar="${jar.location}" fork="true" failonerror="true" >
         <jvmarg value="-Xdebug" />
 <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9000" />

For address, specify the port you know is open and can be accessed from outside.

2. In eclipse open the project which contains the sources and click Debug -> Debug Configurations. Double click to create new debug configuration.
Set the correct Connection Properties: Host (the target host) and Port the port you specified earlier.

3. Click apply and debug…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s