Build Java Web Apps with VS Code

This 5 minutes tutorial shows you how to create a simple Java web application with Visual Studio Code. You'll learn how to run and debug it locally, and prepare for running it in the cloud.


A simple Spring Boot Getting Started web app

Greeting from Java

Before you begin

Before running and deploying this sample, you must have JDK and Maven on your local development environment. If not, please install them.

Download and install the Java SE Development Kit (JDK), version 8:

Download JDK

Note: The JAVA_HOME environment variable must be set to the install location of the JDK to complete this tutorial.

Download Apache Maven version 3 or greater:

Download Apache Maven

Install Apache Maven for your local development environment:

Install Apache Maven

Download and test the Spring Boot app

Clone the Spring Boot Getting Started sample project to your local machine. You can clone a Git repository with the Git: Clone command in the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)). Paste as the URL of the remote repository and then decide the parent directory under which to put the local repository. After that, you can open the cloned repository in VS Code.

Note: You can install Visual Studio Code from and Git from

Clone Spring Repository

After cloning the repo, navigate to the complete folder that contains the project which is ready to run. Open any of the Java files in the repository (for example complete\src\main\java\hello\ If you haven't got the Java related extensions installed with your VS Code, you will be prompted to install the Java Extension Pack. Just follow the instruction and install the Java Extension Pack from Microsoft. Reload VS Code after the installation.

Install Java Extensions

Once you have the Extension Pack installed, it will automatically build the project for you (this may take several minutes). You can run the application within VS Code by pressing F5 and selecting the Java environment. The Java Debug extension will generate a debugging configuration file launch.json for you under a .vscode folder in your project. You can see the progress in the VS Code Status Bar and see the final active debug configuration displayed.

debug configuration in the Status Bar

You can learn more about how VS Code launches your app at Launch Configurations. Press F5 again to launch the debugger.

Run Spring Boot

Test the web app by browsing to http://localhost:8080 using a web browser. You should see the following message displayed: "Greetings from Spring Boot!".

Greeting from Spring

Make a change

Let's now edit to change "Greetings from Spring Boot!" to something else like "Hello World". VS Code provide a great editing experience for Java, check out Editing and Navigating Code to learn about VS Code's editing and code navigation features.

Click the Restart button on the top of the editor to reload the app and see result by reloading the browser.

Restart Application

Debug the application

Set a breakpoint in the application source code, and reload your browser to hit the breakpoint.

Debug Application

If you would like to learn more about debugging Java with VS Code, please read Java Debugging.

Congratulations, you have your first Spring Boot web app running locally! Read on to learn how to host it in the cloud.

Next steps