Running and debugging Java

Visual Studio Code allows you to debug Java applications through the Debugger for Java extension. It's a lightweight Java debugger based on Java Debug Server, which extends the Language Support for Java™ by Red Hat.

Here's a list of supported debugging features:

  • Launch/Attach
  • Breakpoints
  • Exceptions
  • Pause & Continue
  • Step In/Out/Over
  • Variables
  • Call Stacks
  • Threads
  • Debug Console
  • Evaluation
  • Hot Code Replace

The Java debugger is an open-source project, which welcomes contributors to collaborate through GitHub repositories:

If you run into any issues when using the features below, you can contact us by entering an issue.

Install

To get the complete Java language support in Visual Studio Code, you can install the Extension Pack for Java, which includes the Debugger for Java extension.

Install the Extension Pack for Java

For details on how to get started with the extension pack, you can review the Getting Started with Java tutorial.

Configure

By default, the debugger will run out-of-box by automatically finding the main class and generating a default launch configuration in memory to launch your application.

If you would like to customize and persist your launch configuration, you can select the create a launch.json file link in the Run and Debug view.

Debug Menu

The launch.json file is located in a .vscode folder in your workspace (project root folder).

For more details on how to create the launch.json, read Launch configurations; for more details on configuration options for Java, you can read Configuration options.

Run and Debug