Skip to content

java.configuration.runtimes in settings.json are ignored #2001

Closed

Description

@william-mason

[provide a description of the issue]

Environment
  • Operating System: Ubuntu linux 20.10
  • JDK version: several -- 1.8, 16
  • Visual Studio Code version: 1.52.1
  • Java extension version: v0.78.0
Steps To Reproduce
  1. Open VS Code
  2. Open settings preferences
  3. Enter/search for: java.configuration.runtimes
  4. Enter name and path for different JDK-s
  5. Nominate a default

There is no project yet -- I can't even establish a session with the JDK of choice. Also the plugin goes off and finds some Java JDK-s that are not the ones I wish to use. There does not seem to be any place were I can say what I need to use in the project.

Please attach logs

  • This gave me the following error:

    Command 'Java: Open Java Language Server Log File' resulted in an error (command 'java.open.serverLog' not found)
    
Current Result
  • JDK-s configured do not show in the 'Configure Java Runtime' on any tab.
Expected Result
  • I at least wanted to see the Java versions I entered show up as project JDK-s
  • I would also like them to show in the list of "instaled Java-s"
  • I would like a place where I can explicitly specify which Java versions I want the Java Plugin to recognise -- ALL those I want to use at a particular time and No Other JDK-s even if there are installed.
    • Not all the relevant JDK-s are available in "expected" locations
Additional Informations

Activity

  1. rgrunber commented on Jun 28, 2021

    @rgrunber
    Member

    There's a few issues I see here :

    • It looks like you're using the "Configure Java Runtime" from https://github.com/microsoft/vscode-java-pack and there may be some limitations on how it can be configured. With that said, I think you need to have some project imported before being able to configure the runtime in the "Project JDKs" tab. Build systems tend to allow configuring the source/compiler targets, so usually such changes need to be made there. @testforstephen, thoughts ? There might be some enhancements that could be made to give users more control here.
    • The "Configure Java Runtime" doesn't seem to be reading in any values a user may have set in java.configuration.runtimes
    • Java commands contributed via package.json will fail if the extension itself hasn't been triggered (ie. due to no project imported). I wonder if we can fix this.
    • There may be some locations we miss for locating java installations, though we do check JAVA_HOME, JDK_HOME, PATH, and /usr/lib/jvm/ on Linux. Are there additional locations ?
  2. testforstephen commented on Jun 29, 2021

    @testforstephen
    Collaborator
    • When you open a workspace without a project, we leave the "Project JDKs" empty, which is by design. The "Configure Java Runtime" guide is just used to make the JDKs used by your project and the Java tooling itself more transparent.
    • The tool doesn't change your Java version, as the Java version of your project is provided by your build system. It simply allows you to change the mapping between Java version and the JDK used to compile and run your project. Also, it's tricky to let user to modify the build file directly from Java extension, we just provide some hints on how to modify it in build script.
      image
    • When "Project JDKs" shows the JDK for your Java project version, it reads the values from java.configuration.runtimes.
    • The "Installed JDKs" only lists the JDKs from the common places of each OS. There is room to improve it.(findJavaRuntimes should search in more paths microsoft/vscode-java-pack#596). And some specified locations used by java.configuration.runtimes are not listed there, it is a bug.
  3. anandbibek commented on Jul 22, 2021

    @anandbibek

    @testforstephen I've 3 different JDK listed in java.configuration.runtimes.
    Is it possible to set different JDK for different workspaces that are not managed by build tools?

    What I found is that marking one runtime as 'default' lets it get picked up by VSCode, but I am looking for a per workspace setting.

  4. rgrunber commented on Dec 7, 2021

    @rgrunber
    Member

    @testforstephen I've 3 different JDK listed in java.configuration.runtimes. Is it possible to set different JDK for different workspaces that are not managed by build tools?

    What I found is that marking one runtime as 'default' lets it get picked up by VSCode, but I am looking for a per workspace setting.

    java.configuration.runtimes has machine scope, so it cannot be configured per-workspace. What if we were to introduce some setting : java.project.runtime that takes on one of the values from name property of java.configuration.runtimes. If detected, it'd override the default runtime specified there. This wouldn't expose the project to any of the runtime paths, but give it the ability to have a preferred runtime (if configured).

  5. selliera commented on Feb 5, 2022

    @selliera

    Hello,
    This proposition will be very helpful. When one has several java projects not managed by build tools, requiring different versions of java (e.g. 1.8 versus 11), it is very annoying to have to change the default runtime each time one switch from one project to the other.
    Also, this can provide a good solution to #1684 when not using the build tools.

    A similar proposition was made for #1555 by @n-peugnet

  6. thakkarparth007 commented on Mar 2, 2022

    @thakkarparth007
    Contributor

    Just adding some noise here to bump up the priority of the issue. It would be super useful to have this setting workspace-configurable! Seems like it should be a quick fix, I'd be happy to chip in a PR if someone could give a starting pointer.

  7. added this to the End March 2022 milestone on Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions