2 Minutes To Code (β Version)

Debugging with Eclipse - 2 minute tutorial

How to debug a java app running on a remote server

Remove debugging is a 2 step process : running the java program in one jvm process & the debugger in a separate process on same or different machine. The debugger will run in Eclipse on your local system.

I. Running the java app

The first step is to run the java app. While starting the app, you need to pass the java command, a few options as in java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y AppLauncher where AppLauncher is the main class of your java application.

Here, address will be set to debug port, through which debugger connects to java app. The option suspend=y implies that jvm will start up but the program will be suspended. The program will start only when a debugger connects to the jvm. If you set suspend=n, then program will start up without waiting for debugger. However, debug can connect later seamlessly.


II. Running Eclipse debugger and connecting to the java app

Now that the java app's jvm is running, let's see how to connect the debugger to it. The steps are shown in the 3 images below. These steps are :
First click on the debug option (highlighted in image below )and then Debug Configurations.


In the window that opens, double click on Remote Java Application

In the right-hand pane, browse to the workspace project that you need to debug, in the Host input box, add the ip address of the machine where your java application that is to be debugged is running or localhost for local system. In the Port input box, set the same port( 8000 in the example above) that is used in the option address while launching the java app.

Finally, just hit debug button at the bottom of the page and the debugging session will start.

Let's walk through a typical debugging session in the next page.