Visual Studio Code

Intro to VSCode and the Java toolchain.
Author

Chuck Nelson

Published

August 25, 2025

1 Overview

Tip🚀 Using the provided virtual machine?

If you are using the virtual disk provided by your instructor, you’re all set! There is no need to install anything or configure your environment manually. It’s all done for you. Skip ahead to Configure Formatters and Linters or Create a Maven Project.

This guide walks you through setting up Visual Studio Code (VS Code) for Java development using:

  • OpenJDK 21 as the Java Development Kit
  • Apache Maven as the build system
  • Hoppscotch for testing REST APIs
  • Formatters and linters for Java, JSON, YAML, SQL, and XML

Instructions are provided for Linux, Windows, and macOS.

2 Install VS Code

Depending on your distribution type, follow the instructions for:

Download and install from https://code.visualstudio.com

Installation using Scoop is also possible.

scoop bucket add extras 
scoop install vscode

Use Homebrew to install VS Code:

brew install --cask visual-studio-code

3 Install OpenJDK 21

For RHEL, Fedora, and CentOS based distributions.

sudo dnf install java-21-openjdk

For Debian and Ubuntu based distributions.

sudo apt install openjdk-21-jdk

Download the OpenJDK 21 installer from https://jdk.java.net/21/ and follow the installation instructions.

brew install openjdk@21
sudo ln -sfn /opt/homebrew/opt/openjdk@21/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-21.jdk

4 Install Apache Maven

For RHEL, Fedora, and CentOS based distributions.

sudo dnf install maven

For Debian and Ubuntu based distributions.

sudo apt install maven

Follow the binary distribution installation instructions at https://maven.apache.org/install.html.

Installation on Windows is also supported by Scoop.

scoop install main/maven
brew install maven

5 Install VS Code Extensions

On the Visual Studio Marketplace you can find many extensions to exend the capabilities of VSCode according to your development needs. For developing java applications, we’ll use several extensions.

Open VS Code and install the following extensions:

  • Java Development Kit: Extension Pack for Java by Microsoft
  • JSON: JSON Tools, Prettier - Code formatter
  • YAML: YAML Language Support by Red Hat
  • SQL: Matheus Teixeira SQLTools
  • XML: RedHat XML Tools
  • TOML: Even Better TOML
  • Code Assist: Google Gemini Code Assist
  • Maven Support: Maven for Java by Microsoft

You can install them via the Extensions sidebar in VSCode or from the command line:

code --install-extension vscjava.vscode-java-pack
code --install-extension esbenp.prettier-vscode
code --install-extension redhat.vscode-yaml
code --install-extension mtxr.sqltools
code --install-extension redhat.vscode-xml
code --install-extension tamasfe.even-better-toml
code --install-extension Google.geminicodeassist
code --install-extension vscjava.vscode-maven

6 Configure Formatters and Linters

In VS Code, go to Settings > Extensions and configure each formatter/linter as needed. You can also add settings to your settings.json:

{
  "editor.formatOnSave": true,
  "[java]": {
    "editor.defaultFormatter": "redhat.java"
  },
  "[json]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[yaml]": {
    "editor.defaultFormatter": "redhat.vscode-yaml"
  },
  "[sql]": {
    "editor.defaultFormatter": "mtxr.sqltools"
  },
  "[xml]": {
    "editor.defaultFormatter": "redhat.vscode-xml"
  },
  "[toml]": {
    "editor.defaultFormatter": "tamasfe.even-better-toml"
  }
}

7 Create a Maven Project

Now that VSCode is setup, test your installation by creating a practice Maven project from scratch. Maven can use built-in archetypes to scaffold out a new project. The see the different archtype artifact ID’s for Maven, visit https://maven.apache.org/archetypes/.

Use the Maven archetype to create a new project:

mvn archetype:generate -DgroupId=com.example -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Open the project folder in VS Code and start coding!

Back to top