This guide will help you set up a complete Java development environment in Visual Studio Code without using containers.
Before you begin, make sure you have the following installed on your machine:
Install one or more JDK versions. We recommend installing LTS (Long-Term Support) versions:
- Java 11 (LTS)
- Java 17 (LTS)
- Java 21 (LTS - Recommended)
Windows:
macOS:
# Using Homebrew
brew install openjdk@21
# Or download from Oracle/AdoptiumDefault location: /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home
Linux:
# Ubuntu/Debian
sudo apt update
sudo apt install openjdk-21-jdk
# Fedora/RHEL
sudo dnf install java-21-openjdk-develDefault location: /usr/lib/jvm/java-21-openjdk
Maven:
# Windows (using Chocolatey)
choco install maven
# macOS
brew install maven
# Linux (Ubuntu/Debian)
sudo apt install mavenGradle:
# Windows (using Chocolatey)
choco install gradle
# macOS
brew install gradle
# Linux (Ubuntu/Debian)
sudo apt install gradleDownload and install VS Code from code.visualstudio.com
Open VS Code and install the following extensions. You can do this by:
- Opening the Extensions view (
Ctrl+Shift+XorCmd+Shift+X) - Searching for each extension by name
- Clicking "Install"
- Extension Pack for Java (
vscjava.vscode-java-pack) - Includes all core Java extensions - Language Support for Java (
redhat.java) - Java language server - Debugger for Java (
vscjava.vscode-java-debug) - Debugging support - Test Runner for Java (
vscjava.vscode-java-test) - Run and debug tests - Maven for Java (
vscjava.vscode-maven) - Maven integration - Gradle for Java (
vscjava.vscode-gradle) - Gradle integration
- Spring Boot Extension Pack (
vmware.vscode-spring-boot) - If using Spring Boot - SonarLint (
sonarsource.sonarlint-vscode) - Code quality analysis - Checkstyle (
shengchen.vscode-checkstyle) - Java code style checking - IntelliCode (
visualstudioexptteam.vscodeintellicode) - AI-assisted coding - GitHub Copilot (
github.copilot) - AI pair programmer - GitLens (
eamodio.gitlens) - Enhanced Git integration
In your Java project root, create a .vscode folder with the configuration files:
your-project/
├── .vscode/
│ ├── settings.json
│ ├── extensions.json
│ └── launch.json
├── src/
└── pom.xml (or build.gradle)
Copy the provided configuration files into the .vscode folder.
Open .vscode/settings.json and update the java.configuration.runtimes section with your actual JDK installation paths.
Find your Java installation path:
# Windows (PowerShell)
where java
# macOS/Linux
which java
readlink -f $(which java)Update the settings:
Replace the paths in
Note: I used a - instead of / since the gist won't allow the / character