microsoft / microsoft/vscode-java-pack

Feature Request: Set `default` in `java.configuration.runtimes` to the workspace environment variable JAVA_HOME

Open
#1,293 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ai-triaged enhancement
Dominant language
TypeScript
Stars
352
Forks
166
Avg merge
17h 47m
Merged PRs (30d)
32

Description

Currently, the default of the Java extension java.configuration.runtimes is used as the default for No Build Tools, but it would be useful to set it to the environment variable JAVA_HOME which is valid for each workspace. The environment variable here is not the terminal, but process.env.JAVA_HOME, which is referenced by extensions such as

  • java.import.gradle.java.home
    Setting > java.jdt.ls.java.home > JAVA_HOME > PATH
  • maven.terminal.customEnv
    Setting > JAVA_HOME
  • java.jdt.ls.java.home
    Setting > Embedded JRE > JDK_HOME > JAVA_HOME > PATH
  • spring-boot.ls.java.home
    Setting > Embedded JRE > JAVA_HOME > PATH
  • rsp-ui.rsp.java.home
    Setting > JDK_HOME > JAVA_HOME> Windows Registry > PATH
  • salesforcedx-vscode-apex.java.home
    Setting > JDK_HOME > JAVA_HOME> Windows Registry > PATH
  • plantuml.java
    Setting > PATH

The goal is to be able to use a different JAVA_HOME for each workspace, independent of the system's JAVA_HOME environment variable. For example:

User settings.json

"java.configuration.runtimes": [
	{
		"name": "JavaSE-17",
		"path": "/path/to/java/17",
		"default": true
	},
	{
		"name": "JavaSE-21",
		"path": "/path/to/java/21",
	}
],

Workspace settings.json (Override default runtime to JavaSE-21)

"java.configuration.runtimes": [
	{
		"name": "JavaSE-21",
		"path": "/path/to/java/21",
		"default": true
	}
],

java.configuration.runtimes is a Red Hat extension, but I am posting it here because I believe it needs to be supported by VSCode itself. It is related to the following issues.
#152806 API: allow an extension to change the environment variables

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the related VS Code API issue #152806 and the workspace and user settings examples in this issue. Done means determining whether workspace process.env.JAVA_HOME can override the default Java runtime independently of the system environment, with the behavior applying to the listed Java-related settings.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, vscode
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.