Remote Debugging in the Cloud: Easier than Ever

| August 27, 2012

One of the cool things that you can do while using Public IPs in Jelastic is remote debugging. All you have to do to debug your application running on Jelastic is connect it with code in your IDE. One of the greatest benefits is that you get the ability to execute an application on a machine that is separate from the debugger, allowing you to debug issues that are reproducible on only certain machines, or even debug across platforms.

Note: this feature is available beginning from version 1.8.2.

Let's take a quick look out how remote debugging works.

How does remote debugging work?

Java provides this feature using the listener binding mechanism. The basic concept is pretty easy:

  • the application to be debugged will attach a socket to itself and then will listen for debug instructions on that socket
  • debugger will bind itself to that socket and then send instructions on that socket

So, now we'll show you how to connect to different application servers in Jelastic (Tomcat, Jetty and Glassfish) to debug your code remotely. So, let's get started!

Create environment

1. Go to and sign up if you haven't done it yet or log in with your Jelastic credentials by clicking the Sign In link on the page.

2. Ask Jelastic to create a new environment.

3. Choose the instances you want to use (for example, Tomcat application server), set the cloudlets limit and switch on external IP. Then type the name of environment and click Create.


The environment will be created in just a minute.

4. Expand the list of environment and use Additionally button for your instance to see the number of your Public IP.


Deploy an application

1. Upload your Java package to the Deployment manager.

2. Once the package is in Jelastic, deploy it to the environment you have just created.

As an example we use simple application, which initializes three variables (a, b, c) in turn.

package com;
public class RemoteDebugger {
public void start () {
int a,b,c;
a = 1;
System.out.println("a = "+ a);
b = 2;
System.out.println("b = "+ b);
c = 3;
System.out.println("СЃ = "+ c);

Configure debugging

1. Open the application in your IDE (e.g. NetBeans) and create a new debugger (Debug main project >Attach Debugger).

2. Select the type of connector, insert your Public IP address (host), the number of the port you would like to listen to and specify timeout settings (optional).

3. Switch back to Jelastic dashboard and click the Config button for Tomcat.

4. Navigate to variables.conf file and supply two arguments, -Xdebug and -Xrunjdwp.

-Xdebug tells JVM to run the application in debug mode, while -Xrunjdwp is used to supply debug parameters.

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

Note: The port number in variables.conf and in your debugger should be the same.

5. Save the changes and restart Tomcat.

6. Put the break point to your code to test remote debugging and start the newly created debugger. In our case the application should initialize only two variables instead of three.

Let's check Tomcat logs in Jelastic to ensure that debugging works properly.

As you see all is ok, two variables were initialized.

7. If we put the break point one row down, three variables will be initialized by our app.

The instructions above are suitable for Jetty application server as well.

In case if you use GlassFish as your application server you have to supply -Xdebug and -Xrunjdwp arguments via Admin page.

  • When you created the environment, Jelastic sent you an email with credentials to the GlassFish Admin Console. Log in with these credentials.
  • Navigate to gfcluster-config > JVM options and add two arguments: -Xdebug and


Save all changes and restart GlassFish.

Hope you found these instructions useful. Stay tuned to our blog for even more exciting stuff!

Related articles: