Debug Java


By default, the JVM doesn't enable debugging. This is because debugging creates additional overhead inside the JVM. It can also be a security concern for applications that are publicly accessible.

Before we can attach a debugger, we must first configure the JVM to allow debugging. We'll do this by setting a command line argument for the JVM:


Once the connection is established, we can proceed to setting up debugging.


  1. Go to the Run and debug panel on the left navigation menu, then click create a launch.json file.
  1. Add a Attach: Java configuration (or ensure you already have it) under configurations. Update the port if needed.
"configurations": [
    "type": "java",
    "name": "Debug remote",
    "request": "attach",
    "hostName": "localhost",
    "port": "5005"

You will be able to see the new configuration in the top of the screen.

  1. Open a terminal and start the JVM process with debugging enabled.
  1. Click the green play button next to the configuration name. You will notice the layout of VS Code changing for debugging.

  2. Add a breakpoint.

  1. Access the endpoint of the application to generate a request, and you will notice the breakpoint being hit.

Congratulations! You have now got a completely working environment for Remote Development in the cloud.