redhat-developer / redhat-developer/vscode-java

`java.jdt.ls.java.home` should use the Java execution environment name

Open
#4,422 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

Description

I've been trying to configure several Java projects in Visual Studio Code and have noticed that the java.jdt.ls.java.home setting, among others, is always required.

This setting belongs in the project's workspace (unless you work in one project, or have a perfectly aligned setup), but it cannot be set as such because for a multi-user project, each one will definitely have a different path for the JDK.

I think it would be great if this setting could take the (reference) value of one the existing Java execution environments instead, and tries to read the path of the corresponding JDK. This way, the configuration is fixed, set at the project level, and only needs to change if the project upgrades to a newer JDK.

For instance:

// Global User Settings
{
  ...
  "java.configuration.runtimes": [
    {
      "javadoc": "https://docs.oracle.com/en/java/javase/17/docs/api/index.html",
      "name": "JavaSE-17",
      "path": "/home/x80486/.local/share/mise/installs/java/temurin-17",
      "sources": "/home/x80486/.local/share/mise/installs/java/temurin-17/lib/src.zip"
    },
    {
      "default": true,
      "javadoc": "https://docs.oracle.com/en/java/javase/21/docs/api/index.html",
      "name": "JavaSE-21",
      "path": "/home/x80486/.local/share/mise/installs/java/temurin-21",
      "sources": "/home/x80486/.local/share/mise/installs/java/temurin-21/lib/src.zip"
    }
  ],
  ...
}

Then for each project I work on, I could just set in .vscode/settings.json:

{
  "java.jdt.ls.java.home": "JavaSE-21"
}

Additional Context

This is just an idea with the existing settings. It may be even more appropriate to define something new that could unify all the settings that request the location of the JDK, but it should always refer in one way or another to the java.configuration.runtimes (preferably by name), otherwise it's impossible to set this correctly —in a way that works for everyone regardless of the architecture and location/installation of the Java SDK—, at the project level.

Contributor guide

Open the contributing guide

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

No implementation files or tests are named. Start with the handling of java.jdt.ls.java.home and java.configuration.runtimes, using the .vscode/settings.json example as the workspace-level entry point. Done means a project can select a runtime by its execution-environment name while each user resolves that name to their own JDK path.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.