Skip to content

cypher256/java-extension-pack

Repository files navigation

Extension Pack for Java Auto Config

Java 23 Ready Downloads Installes Buy Me a Coffee


Overview

Just install this extension and start Java development right out of the box with zero configuration.


Open Terminals by Java Version

This extension adds the Java versions available in your current environment to the VS Code terminal profiles dropdown. Select the Java version you want to use, open a new terminal, and you can check the version with the following commands. While the latest versions of Gradle and Maven are available, it's generally recommended to use wrappers (gradlew, mvnw) for each project.

java -version
gradle -v
mvn -v

Terminal Java Dropdown


Set Default Java Version

The built-in Select Default Profile in VSCode only changes the default terminal profile. However, this extension applies the selected profile's Java version to all Java-related settings (⭐) within the user (global) settings.json. To specify a different Java version for individual settings, edit the following files.

  • General (vscode-java)
    (*1) User settings.json (Java runtimes common settings)

    "java.configuration.runtimes": [
      {
        "name": "JavaSE-1.8",
        "path": "C:\\Program Files\\java\\jdk-1.8.0_402",
      },
      {
        "name": "JavaSE-11",
        "path": "C:\\Program Files\\java\\jdk-11.0.21",
      },
      {
        "name": "JavaSE-17",
        "path": "C:\\Program Files\\java\\jdk-17.0.12"
      },
      {
        "name": "JavaSE-21",
        "path": "C:\\Program Files\\java\\jdk-21.0.8",
        "default": true //⭐ default when creating "No build tools" project
      }
    ]

  • Gradle (vscode-gradle)
    (*1) User settings.json (Gradle execution runtime)

    "java.import.gradle.java.home": "C:\\Program Files\\java\\jdk-21.0.8" //⭐

    (*2) Project build.gradle (options.release)

    def javaVersion = 17
    java.sourceCompatibility = javaVersion // Make it recognize to VS Code
    compileJava.options.release = javaVersion // JEP 247: API validation

    The Gradle Toolchain allows you to specify the exact JDK version to use for building.

    java.toolchain.languageVersion = JavaLanguageVersion.of(17)

  • Maven (vscode-maven)
    (*1) User settings.json (Maven execution runtime)

    "maven.terminal.customEnv": [
      {
        "environmentVariable": "JAVA_HOME",
        "value": "C:\\Program Files\\java\\jdk-21.0.8" //⭐
      }
    ]

    (*2) Project pom.xml (maven.compiler.release)

    <properties>
        <!-- <maven.compiler.source>17</maven.compiler.source> -->
        <!-- <maven.compiler.target>17</maven.compiler.target> -->
        <maven.compiler.release>17</maven.compiler.release><!-- JEP 247: API validation -->
    </properties>

    The Maven Toolchain allows you to specify the exact JDK version to use for building.

(*1) The settings.json can be overridden by the project (workspace).
(*2) The java.configuration.runtimes that best matches this version will be used. Setting the release ensures the specified version syntax and API are used, regardless of which compiler version actually performs the compilation.




Features

JDKs, build tools, terminal settings, and other configurations are automatically set up and updated at startup based on the current environment, as shown below. If you want to disable all auto-configuration features, set javaAutoConfig.enabled to false. However, java.import.gradle.java.home and maven.executable.path are always prepended to the PATH in the terminal.

JDK Auto-Configuration

Automatically configure multiple versions of the JDK and build tools. If there are multiple JDKs of the same version, the latest minor version will be used. If you installed the JDK manually or encountered a configuration error, restart VS Code or execute >Java: Clean Java Language Server Workspace ≫ Reload and delete from the Command Palette. These settings are applied to the user settings.json (VS Code global), but can be manually edited for customization. If you want to further customize your setup, consider using workspace settings or profiles.

  1. Auto-fix invalid JDK configuration (e.g. /foo/jdk-21.0.8/bin -> /foo/jdk-21.0.8)
  2. Auto-remove configuration entries when JDK uninstalled or version path changed
  3. Auto-scan from OS specific locations, Package Managers and Toolchains (See next section)
  4. Auto-detect environment variables JAVA_HOME, JDK_HOME and PATH
  5. Auto-download Adoptium LTS JDKs, Gradle, Maven if not detected
  6. Auto-update auto-downloaded JDKs, Gradle, Maven to the latest version

Best Auto-Scan

  • OS specific locations: Adoptium, BellSoft, Corretto, Microsoft, Oracle, Red Hat, Semeru, Zulu etc...
  • Package Managers: asdf, Chocolatey, jabba, jEnv, Homebrew, IntelliJ, mise, Scoop, SDKMAN, vfox etc...
  • Toolchains: Gradle jdks directory, Maven toolchains.xml
  • Own Support: Windows C:\Java\*, D:\Java\* (e.g. C:\Java\jdk-21.0.8)

The feature automatically fixes errors such as

  • Java Language Server requires a JDK xx+ to launch itself.
  • This setting is deprecated, please use 'java.jdt.ls.java.home' instead.
  • Invalid runtime for JavaSE-xx: The path points to a missing or inaccessible folder
  • The java.jdt.ls.java.home variable defined in Visual Studio Code settings points to a missing or inaccessible folder

For Included Extensions

Configuration Name Configured Value [Precedence]
Language support for Java
java.configuration.runtimes
(Issues) ⭐ default
Set all detected and downloaded JDKs (default: Latest)
[This setting > JAVA_HOME]
java.jdt.ls.java.home
(Issues) 🛠️
Fix if invalid
[This setting > Embedded JRE > JDK_HOME > JAVA_HOME > PATH]
java.home Remove as it has been replaced by java.jdt.ls.java.home
Spring Boot Tools
spring-boot.ls.java.home
(Issues) 🛠️
Fix if invalid
[This setting > Embedded JRE > JAVA_HOME > PATH]
Gradle for Java
java.import.gradle.java.home
(Issues) ⭐
Set latest LTS JDK if unset
[This setting > Embedded JRE > java.jdt.ls.java.home > JAVA_HOME > PATH > jdk-utils > java.configuration.runtimes default]
java.import.gradle.home
(Issues)
Set auto-downloaded gradle if unset
[gradlew > This setting > PATH > GRADLE_HOME]
Maven for Java
maven.terminal.customEnv
(Issues) ⭐
Set latest LTS JDK if unset
[This setting > JAVA_HOME]
maven.executable.path
(Issues) 📝
Set auto-downloaded maven if unset (If you want to use mvnw, set "" manually)
[This setting > mvnw > PATH]

For Optional Extensions (If installed)

Configuration Name Configured Value [Precedence]
IBM Z Open Editor
zopeneditor.JAVA_HOME
(Issues) 🛠️📝
Set previous LTS if unset
[This setting > JAVA_HOME > PATH]
PlantUML
plantuml.java
(Issues) 🛠️
Set stable LTS if unset
[This setting > PATH]
Runtime Server Protocol UI
rsp-ui.rsp.java.home
(Issues) 🛠️
Set stable LTS if unset
[This setting > JDK_HOME > JAVA_HOME > Windows Registry > PATH]
Salesforce Extension Pack
salesforcedx-vscode-apex.java.home
(Issues) 🛠️
Set previous LTS if unset
[This setting > JDK_HOME > JAVA_HOME > Windows Registry > PATH]
Scala (Metals)
metals.javaHome
(Issues) 🛠️
Set previous LTS if unset
[This setting > JAVA_HOME > Windows Registry > PATH]

⭐ The Java version specified in Select Default Profile is set.
🛠️ The language server runtime used by VS Code extensions. Not for building or running projects.
📝 This setting cannot be overridden per workspace (project).

Auto-Download Support

Automatic downloads are enabled if the extensions.autoUpdate setting is NOT set to false. Java will download multiple versions, but Gradle and Maven will only download the latest version. If you use an older version of Gradle/Maven due to compatibility issues, consider using gradlew (Compatibility) or mvnw (Compatibility) in your project or manually set java.import.gradle.home or maven.executable.path in settings.json.

JDK auto-download supports the following platforms:

  • Windows x64, ARM Emulation
  • Mac x64, aarch64
  • Linux x64, aarch64

It is saved in the following location.

OS Extension global storage location
Windows %APPDATA%\Code\User\globalStorage\pleiades.java-extension-pack-jdk\
Mac $HOME/Library/Application Support/Code/User/globalStorage/pleiades.java-extension-pack-jdk/
Linux $HOME/.config/Code/User/globalStorage/pleiades.java-extension-pack-jdk/

e.g. Auto-configured User settings.json

Command Palette >Preferences: Open User Settings (JSON)

// Project Runtimes (multiple versions)
"java.configuration.runtimes": [
  {
    "name": "JavaSE-1.8", // Adoptium (Auto-download)
    "path": "C:\\Users\\<UserName>\\AppData\\Roaming\\Code\\User\\globalStorage\\pleiades.java-extension-pack-jdk\\java\\8"
  },
  {
    "name": "JavaSE-11", // Corretto (Auto-scan)
    "path": "C:\\Program Files\\Amazon Corretto\\jdk11.0.18_10"
  },
  {
    "name": "JavaSE-17", // Oracle (Auto-scan)
    "path": "C:\\Program Files\\java\\jdk-17.0.12"
  },
  {
    "name": "JavaSE-21", // Adoptium (Auto-scan)
    "path": "C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.8-hotspot",
    "default": true //⭐
  }
],
// Gradle Daemon Java Runtime
"java.import.gradle.java.home": "C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.8-hotspot", //⭐
// Maven Environment Variables (for GUI context menu)
"maven.terminal.customEnv": [
  {
    "environmentVariable": "JAVA_HOME",
    "value": "C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.8-hotspot" //⭐
  }
],


Terminal Auto-Configuration

The terminal dropdown items by Java version are automatically created based on the java.configuration.runtimes above. You can easily open a terminal by selecting the Java version from command >Terminal: Create New Terminal (With Profile) or Terminal (Ctrl + `) ≫ Profiles dropdown. Besides java, gradle and mvn commands can also be used. The configured environment variables have no effect outside the terminal, so the system and OS user environment remain clean. The terminal configuration terminal.integrated.profiles is always overwritten from java.configuration.runtimes, so if you want to customize it, copy the terminal configuration entry and create an entry with a different name.

Configuration Name Configured Value [Original Default]
terminal.integrated.env.windows
(Issues) Windows only
Set latest LTS if unset
[None]
terminal.integrated.defaultProfile.{platform}
(Issues)
Set latest LTS profiles name (e.g. JavaSE-21 LTS)
[Windows:cmd, Mac:zsh, Linux:bash]
terminal.integrated.automationProfile.windows
(Issues) Windows only
"path": "cmd"
[null] Suppress error: 'Incorrect parameter format -/d'
terminal.integrated.profiles.{platform}
(Issues) ⭐ Mac:zsh, Linux:bash
Set configured runtimes to terminal
[None]
terminal.integrated.enablePersistentSessions
(Issues)
false
[true]
terminal.integrated.tabs.hideCondition
(Issues)
never
[singleTerminal]
java.test.config > vmArgs
(Issues) Windows only
-Dstdout.encoding=UTF-8, -Derrout.encoding=UTF-8
[undefined]

e.g. Auto-configured User settings.json

Command Palette >Preferences: Open User Settings (JSON)

// Terminal Default Environment Variables
"terminal.integrated.env.windows": {
    "PATH": "C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.8-hotspot\\bin;${env:PATH}", //⭐
    "JAVA_HOME": "C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.8-hotspot"
},
// Terminal Default Profile (Changing this value will set all ⭐)
"terminal.integrated.defaultProfile.windows": "JavaSE-21 LTS",
"terminal.integrated.automationProfile.windows": {
    "path": "cmd"
},
// Terminal Profiles Dropdown
"terminal.integrated.profiles.windows": {
    "JavaSE-1.8 LTS": {...},
    "JavaSE-11 LTS": {...},
    "JavaSE-17 LTS": {
        "overrideName": true,
        "env": {
            "PATH": "C:\\Program Files\\java\\jdk-17.0.12\\bin;${env:PATH}",
            "JAVA_HOME": "C:\\Program Files\\java\\jdk-17.0.12"
        },
        "path": "cmd"
    },
    "JavaSE-21 LTS": {
        "overrideName": true,
        "env": {
            "PATH": "C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.8-hotspot\\bin;${env:PATH}",
            "JAVA_TOOL_OPTIONS": "-Dstdout.encoding=UTF-8 -Dstderr.encoding=UTF-8", // Windows
            "JAVA_HOME": "C:\\Program Files\\Eclipse Adoptium\\jdk-21.0.8-hotspot"
        },
        "path": "cmd",
        // For Windows, auto-configured Java 19+ terminals are set to `chcp 65001`.
        "args": ["/k", "chcp", "65001"]
    }
}


Auto-Default Settings

Entries without the following configurations in the user settings are automatically set to the default values of Extension Pack for Java Auto Config. To prevent automatic configuration, set the original default values listed below. Note that a debug run is required to enable Hot Code Replace (Hot Deploy).

For Included Extensions

Configuration Name Original Default Auto Default
editor.codeActionsOnSave {} Described later
editor.linkedEditing (like Auto Rename Tag) false true
editor.minimap.enabled true false
editor.rulers [] Described later
editor.unicodeHighlight.includeComments inUntrustedWorkspace true
emmet.variables > lang en OS locale
workbench.colorCustomizations {} Described later
workbench.editor.revealIfOpen false true
workbench.tree.indent 8 20
files.eol (For Windows) auto \n
[bat] > files.eol auto \r\n
Language support for Java
java.compile.nullAnalysis.mode interactive automatic
java.configuration.detectJdksAtStart true false
java.configuration.updateBuildConfiguration interactive automatic
java.dependency.packagePresentation flat hierarchical
java.maxConcurrentBuilds 1 Number of logical CPU
java.sources.organizeImports.staticStarThreshold 99 1
Debugger for Java
java.debug.settings.hotCodeReplace
manual auto
Code Spell Checker
cSpell.diagnosticLevel
Information Hint
Trailing Spaces
trailing-spaces.backgroundColor rgba(255,0,0,0.3) rgba(255,0,0,0.1)
trailing-spaces.includeEmptyLines true false

For Optional Extensions (If installed)

Configuration Name Original Default Auto Default
JSP Language Support
emmet.includeLanguages
{} {"jsp": "html"}
Thunder Client
thunder-client.requestLayout
Left/Right Top/Bottom
"editor.codeActionsOnSave": {
  "source.organizeImports": true
},
"editor.rulers": [ // RGBA for transparency
  {
    "column": 80,
    "color": "#00FF0010"
  },
  {
    "column": 100,
    "color": "#BDB76B15"
  },
  {
    "column": 120,
    "color": "#FA807219"
  },
],
"workbench.colorCustomizations": {
  "[Default Dark Modern]": {
    "tab.activeBorderTop": "#00FF00",
    "tab.unfocusedActiveBorderTop" : "#00FF0088",
    "textCodeBlock.background": "#00000055", // Markdown preview code block
  },
  "editor.wordHighlightStrongBorder": "#FF6347", // Write-access
  "editor.wordHighlightBorder": "#FFD700", // Read-access
  "editor.selectionHighlightBorder": "#A9A9A9" // Double click selection
},

Highlight Default Settings




Language Pack Auto-Installation

The language pack corresponding to the OS locale is installed at the first startup.

  • cs, de, es, fr, it, ja, ko, pl, ru, tr, zh-hans or zh-hant

License


Thank you

A big thank you to the developers of VS Code and its extensions.


Included Extensions

The Extension Pack for Java is required. Other extensions can be disabled or uninstalled based on your preference. If you want to configure extensions and configurations by development language, consider using Profiles. Extensions marked with (*) will be installed automatically if available in the environment at first startup. Note that uninstalling the Extension Pack for Java Auto Config will uninstall all of the following extensions.

  • Code Spell Checker (Street Side Software: GPL)
    Spelling checker for source code.
  • (*) Comment Translate (intellsmi: MIT)
    This plugin uses the Google Translate API to translate comments for the VS Code programming language.
  • Extension Pack for Java (Microsoft: MIT, Red Hat: EPL) / VS Code Document
    Java IntelliSense, debugging, testing, Maven/Gradle support, Lombok and more.
  • Indent-Rainbow (oderwat: MIT)
    Makes indentation easier to read.
  • (*) Language Pack (Microsoft: MIT) / VS Code Document
    A language pack that matches the OS Locale.
  • Live Server (Ritwick Dey: MIT)
    Launch a development local Server with live reload feature for static & dynamic pages.
  • Rainbow CSV (mechatroner: MIT)
    Highlight CSV and TSV files, Run SQL-like queries.
  • Spring Boot Extension Pack (Broadcom: EPL) / VS Code Document
    A collection of extensions for developing Spring Boot applications.
  • Todo Tree (Gruntfuggly: MIT)
    Show TODO, FIXME, etc. comment tags in a tree view.
  • Trailing Spaces (Shardul Mahadik: MIT)
    Highlight trailing spaces and delete them in a flash!
  • XML (Red Hat: EPL)
    XML Language Support by Red Hat (pom.xml etc.).



Recommended Extensions

The following are not included but are highly useful extensions. Consider installing them if needed.

  • code-eol 2022 (Jeff Hykin: MIT) / code-eol (sohamkamani: Free)
    Display newline characters in your code. (VSCode does not support CR)
  • Checkstyle (ShengChen: GPL) / VS Code Document
    Provide real-time feedback about Checkstyle violations and quick fix actions.
  • Error Lens (Phil Hindle: MIT)
    Improve highlighting of errors, warnings and other language diagnostics.
  • GistPad (Jonathan Carter: MIT)
    Manage your code snippets and developer notes using GitHub Gists and repositories.
  • GlassIt-VSC (hikarin522: MIT)
    VS Code Extension to set window to transparent on Windows and Linux platforms.
  • Java TestingPair Opener (gengen0719: Apache)
    This is an extension that opens JavaCode's TestingPair with a shortcut-key.
  • JSP Language Support (Samuel Weinhardt: MIT)
    JSP syntax highlighting for VS Code.
  • SonarLint (SonarSource: GPL) / VS Code Document
    Detect and fix quality issues as you write code in C, C++, Java, JavaScript, PHP, Python, HTML and TypeScript.
  • Thunder Client (Ranga Vadhineni: Free)
    Lightweight Rest API Client for VS Code.
  • Thymeleaf HTML5 Snippets (Lalith Kahatapitiya: GPL)
    Most common thymeleaf code snippets for .html file.
  • Thymeleaf Navigation (Stefan Gründel: GPL)
    Navigate Thymeleaf 3 fragments.

Recommended Gradle/Maven plugins that supports Tomcat hot deployment.