Skip to content

Instantly share code, notes, and snippets.

@arilivigni
Created November 6, 2025 16:01
Show Gist options
  • Select an option

  • Save arilivigni/49d60a36cc8d7ae421a43a65e5f7a6ed to your computer and use it in GitHub Desktop.

Select an option

Save arilivigni/49d60a36cc8d7ae421a43a65e5f7a6ed to your computer and use it in GitHub Desktop.
VS Code Java description
{
"recommendations": [
// Essential Java Development
"vscjava.vscode-java-pack",
"redhat.java",
"vscjava.vscode-java-debug",
"vscjava.vscode-java-test",
"vscjava.vscode-java-dependency",
// Build Tools
"vscjava.vscode-maven",
"vscjava.vscode-gradle",
// Spring Boot (if using Spring)
"vmware.vscode-spring-boot",
"vscjava.vscode-spring-initializr",
"vscjava.vscode-spring-boot-dashboard",
// Code Quality
"sonarsource.sonarlint-vscode",
"shengchen.vscode-checkstyle",
// Productivity
"visualstudioexptteam.vscodeintellicode",
"visualstudioexptteam.intellicode-api-usage-examples",
"github.copilot",
"github.copilot-chat",
// Utilities
"streetsidesoftware.code-spell-checker",
"eamodio.gitlens",
"ms-azuretools.vscode-docker"
]
}
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Launch Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "Launch with Arguments",
"request": "launch",
"mainClass": "${file}",
"args": ""
},
{
"type": "java",
"name": "Debug Spring Boot App",
"request": "launch",
"mainClass": "<your.package.Application>",
"projectName": "your-project-name",
"args": "",
"envFile": "${workspaceFolder}/.env"
}
]
}
{
// Java Language Server Settings
"java.configuration.updateBuildConfiguration": "automatic",
"java.autobuild.enabled": true,
"java.compile.nullAnalysis.mode": "automatic",
// Java Runtime Configuration
"java.configuration.runtimes": [
{
"name": "JavaSE-11",
"path": "/usr/lib/jvm/java-11-openjdk",
"default": false
},
{
"name": "JavaSE-17",
"path": "/usr/lib/jvm/java-17-openjdk",
"default": false
},
{
"name": "JavaSE-21",
"path": "/usr/lib/jvm/java-21-openjdk",
"default": true
}
],
// Java Formatting
"java.format.enabled": true,
"java.format.settings.url": "",
"java.format.settings.profile": "GoogleStyle",
"java.format.comments.enabled": true,
"java.saveActions.organizeImports": true,
// Java Code Generation
"java.codeGeneration.generateComments": true,
"java.codeGeneration.useBlocks": true,
"java.codeGeneration.hashCodeEquals.useJava7Objects": true,
"java.codeGeneration.insertionLocation": "afterCursor",
// Maven Settings
"maven.executable.path": "",
"maven.terminal.useJavaHome": true,
"maven.view": "hierarchical",
// Gradle Settings
"java.import.gradle.enabled": true,
"java.import.gradle.wrapper.enabled": true,
"java.import.gradle.java.home": "",
// Testing
"java.test.config": {},
"java.test.defaultConfig": "",
// Debugging
"java.debug.settings.hotCodeReplace": "auto",
"java.debug.settings.enableRunDebugCodeLens": true,
"java.debug.settings.showHex": false,
"java.debug.settings.showStaticVariables": true,
"java.debug.settings.showQualifiedNames": false,
"java.debug.settings.maxStringLength": 0,
// IntelliSense and Completion
"java.completion.enabled": true,
"java.completion.guessMethodArguments": true,
"java.completion.favoriteStaticMembers": [
"org.junit.Assert.*",
"org.junit.Assume.*",
"org.junit.jupiter.api.Assertions.*",
"org.junit.jupiter.api.Assumptions.*",
"org.junit.jupiter.api.DynamicContainer.*",
"org.junit.jupiter.api.DynamicTest.*",
"org.mockito.Mockito.*",
"org.mockito.ArgumentMatchers.*"
],
"java.completion.filteredTypes": [
"java.awt.*",
"com.sun.*",
"sun.*",
"jdk.*",
"org.graalvm.*",
"io.micrometer.shaded.*"
],
"java.completion.importOrder": [
"java",
"javax",
"com",
"org"
],
// Editor Settings for Java
"editor.formatOnSave": true,
"editor.formatOnPaste": false,
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
// File Association
"files.associations": {
"*.java": "java"
},
"files.encoding": "utf8",
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000,
// Terminal
"terminal.integrated.env.linux": {
"JAVA_HOME": "/usr/lib/jvm/java-21-openjdk"
},
"terminal.integrated.env.osx": {
"JAVA_HOME": "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home"
},
"terminal.integrated.env.windows": {
"JAVA_HOME": "C:\\Program Files\\Java\\jdk-21"
},
// Exclude files from explorer
"files.exclude": {
"**/.classpath": true,
"**/.project": true,
"**/.settings": true,
"**/.factorypath": true
},
// SonarLint
"sonarlint.rules": {
"java:S1118": {
"level": "off"
}
},
// Checkstyle
"java.checkstyle.configuration": "${workspaceFolder}/checkstyle.xml",
"java.checkstyle.version": "10.12.4",
// GitHub Copilot
"github.copilot.enable": {
"*": true,
"java": true
},
// IntelliCode
"java.intellicode.memberSorting": true
}

Java Development Setup for VS Code

This guide will help you set up a complete Java development environment in Visual Studio Code without using containers.

Prerequisites

Before you begin, make sure you have the following installed on your machine:

1. Java Development Kit (JDK)

Install one or more JDK versions. We recommend installing LTS (Long-Term Support) versions:

  • Java 11 (LTS)
  • Java 17 (LTS)
  • Java 21 (LTS - Recommended)

Installation by Operating System

Windows:

  • Download from Oracle or Adoptium
  • Install to default location: C:\Program Files\Java\jdk-21

macOS:

# Using Homebrew
brew install openjdk@21

# Or download from Oracle/Adoptium

Default 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-devel

Default location: /usr/lib/jvm/java-21-openjdk

2. Build Tools (Optional but Recommended)

Maven:

# Windows (using Chocolatey)
choco install maven

# macOS
brew install maven

# Linux (Ubuntu/Debian)
sudo apt install maven

Gradle:

# Windows (using Chocolatey)
choco install gradle

# macOS
brew install gradle

# Linux (Ubuntu/Debian)
sudo apt install gradle

3. Visual Studio Code

Download and install VS Code from code.visualstudio.com

Setup Instructions

Step 1: Install VS Code Extensions

Open VS Code and install the following extensions. You can do this by:

  1. Opening the Extensions view (Ctrl+Shift+X or Cmd+Shift+X)
  2. Searching for each extension by name
  3. Clicking "Install"

Essential Extensions:

  • 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

Recommended Extensions:

  • 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

Step 2: Create Project Configuration

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.

Step 3: Update Java Runtime Paths

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment