Java in Visual Studio Code

The Java support in Visual Studio Code is provided through

and optimized for lightweight Java projects with a simple, modern workflow. Popular extensions in the

provide essential language features such as project support, code completion, linting, debugging, testing, code formatting, snippets, as well as tooling integration including Maven and Tomcat.

Install Java Extensions

VS Code is a fast editor and ships with great editing features. Add Java language support to VS Code by installing the popular Java extensions. To help set up Java on VS Code, there is a
Java Extension Pack

which contains popular extensions we picked for most Java developers:

  1. Language Support for Java(TM) by Red Hat

  2. Debugger for Java

  3. Java Test Runner

  4. Stomach for Java

Install the Java Extension Pack

There are also other popular Java extensions you can pick for your own needs, including:

  1. Spring Boot Support

  2. Spring Initializr Java Support

  3. Tomcat

  4. CheckStyle

Thanks to the great Java community around VS Code, the list doesn’t end there. You can search for more Java extensions easily within VS Code:

  1. Go to theExtensionsview (Ctrl+Shift+X).
  2. Filter the extensions list by typing “java”.

This document describes some of the key features included in those Java extensions.

Java Project Support

Maven, Eclipse and Gradle Java project are supported through
Language Support for Java(TM) by Red Hat

, by utilizing

which provides Maven support and

which provides Gradle support through the
Eclipse JDT Language Server


Maven for Java

, you can generate projects from
Maven Archetype

, browse through all the Maven projects within your workspace, and execute Maven goals easily from an embedded explorer.


Editing and Navigating Code




is a tool that provides warnings for suspicious looking code.
Language Support for Java(TM) by Red Hat

provides this feature to report parsing and compilation errors as you type, so you can fix them inside VS Code.


VS Code also supports code completion and IntelliSense for Java through
Language Support for Java(TM) by Red Hat


is a general term for a number of features, including intelligent code completion (in-context method and variable suggestions) across all your files and for built-in and third-party modules.

Search for symbols

You can search for symbols in the current file or workspace to navigate your code more quickly.

To search for a symbol in the current file, useQuick Open(Ctrl+P) then enter the ‘@’ command, then enter the name of the symbol you’re looking for. A list of potential matches will appear and be filtered as you type. Choose from the list of matches to navigate to its location.

To search for a symbol in the current workspace, start by pressing Ctrl+T, then enter the name of the symbol. A list of potential matches will appear as before. If you choose a match that was found in a file that’s not already open, the file will be opened before navigating to the match’s location. Alternatively, you can also useQuick Open(Ctrl+P) then enter the ‘#’ command to search the current workspace. Ctrl+T is just the shortcut for the ‘#’ commands, respectively, so everything works the same.

Peek Definition

You can take a quick look at how a symbol was defined by using the Peek Definition feature. This feature displays a few lines of code near the definition inside a peek window so you can take a look without navigating away from your current location.

To peek at a symbol’s definition, place your cursor on the symbol anywhere it’s used in your source code and then press Alt+F12. Alternatively, you can choosePeek Definitionfrom the context menu (right-click, then choosePeek Definition).

Go to Definition

You can also quickly navigate to where a symbol is defined by using the Go to Definition feature.

To go to a symbol’s definition, place your cursor on the symbol anywhere it is used in your source code and then press F12. Alternatively, you can chooseGo to Definitionfrom the context menu (right-click, then chooseGo to Definition). When there’s only one definition of the symbol, you’ll navigate directly to its location, otherwise the competing definitions are displayed in a peek window as described in the previous section and you have to choose the definition that you want to go to.

Other code editing features include:

  • Code formatting
  • Code snippets
  • Code outline
  • CodeLens (references)
  • Javadoc hovers
  • Rename
  • Highlights


Debugger for Java

is a lightweight Java Debugger based on
Java Debug Server

. It works with
Language Support for Java by Red Hat

to allow users debugging Java code using Visual Studio Code (VS Code).

The Java Debugger supports following features:

  • Launch/Attach- You can either launch the Java project within VS Code or attach to any running JVM process in debug mode, locally or remotely.
  • Breakpoints- Conditional breakpoints by Hit Count and expression evaluation are supported and can easily be set using the inline breakpoint settings window. This allows you to conveniently add conditional breakpoints to your code, directly in the source viewer, without requiring a modal window. Break on exceptions is also supported.
  • Control flow- IncludingPause,Continue

    ,Step over

    ,Step into

    ,Step out
  • Data inspection- When you’re stopped at a breakpoint, the debugger has access to the variable names and values that are currently stored in memory. Inspect/Watch/Set Variables are supported.
  • Diagnostics- TheCALL STACKpanel shows the call stack of your program and allows you to navigate through the call path of each captured allocation. Multi-threaded debugging is supported by parallel stacks.
  • Debug Console- The Debug Console lets you see information from both stdout and stderr.
  • Hot Code Replacement- A very useful feature to facilitate experimental development and iterative trial-and-error coding.


The debugger is able to detect your launch class in most cases, all you need to do is start debugging by pressing

. If you’d like to define the debugging configuration yourself, just follow the steps below:

  1. Switch to theDebugview (Ctrl+Shift+D).
  2. Open

    to add a debug configuration for Java.
  3. Fill in the


    setting or



  4. ClickStartbutton or press

    to start debugging.


For more debugging related information, please visit
Java Debugging



With the support from the
Java Test Runner

extension, you can easily run, debug and manage your Java test cases.


Your test cases are identified automatically.


Currently the Test Runner supports JUnit4. We’re working on JUnit5 and TestNG and will be supporting them soon.

Spring Boot and Tomcat

To further improve your Java productivity in VS Code, there are extensions for most popular frameworks and tools such as
Spring Boot


created by the community.


extension includes an explorer to easily navigate and manage your Tomcat servers. You can create, start, debug, stop and rename your Tomcat server all with the extension.


Java Tutorial with VS Code

to learn more about Tomcat and basic Java support with VS Code.

Spring Boot

support is provided by an extension from

, who also provide extensions for popular platforms such as Cloudfoundry, Concourse and BOSH. There’s also a
Spring Initializr Java Support

extension so you can create a Spring Boot app from scratch.

Spring Boot with VS Code

to learn more about Spring Boot support with VS Code.