Skip to content

feature request: select java runtime in vs code settings #1684

Open

Description

@thorstenhirsch

The current state of Java runtime support seems to be:

  • this extension needs Java 11
  • you can specify available runtimes in java.configuration.runtimes
  • however you can't specify/force which of these versions to use in a project; instead there's some auto detection that looks into eclipse/maven/gradle config

As we see in #1543 a lot of people are not happy with this situation. Me neither. Please add runtime selection in VS Code settings, so that one can force the usage of e.g. JavaSE-1.8 per workspace or even per directory.

Environment
  • Operating System: Windows 10
  • JDK version: OpenJDK 11 and Corretto JDK 8
  • Visual Studio Code version: 1.50.1
  • Java extension version: redhat.java v0.69.0, vscjava.vscode-java-pack v0.10.0
Steps To Reproduce
  1. install JDK 8
  2. install JDK 11 (-> system default)
  3. open vs code
  4. open a Java project and try to build it with JDK 8 (without changing java.home, because VS Code Java extension requires JDK 11)
Current Result

autodetection might work if eclipse/mvn/gradle settings are found that specify Java 8, otherwise JDK 11 is being used

Expected Result

usage of JDK 8 can be forced by VS Code settings per workspace or per directory

Additional Informations

Activity

  1. bagrupe commented on Oct 30, 2020

    @bagrupe

    I just opened #1687 which is somewhat related to this problem - as soon as you have an "invisible" project you won't have any option to edit the underlying project settings and auto-detection may or may not work depending on the situation. Maybe it should be possible to change an invisible project to a standard eclipse project and add a UI for the most basic settings (e.g. Java runtime used)?

  2. jjoker0110 commented on Nov 4, 2020

    @jjoker0110

    I'm still dealing with this issue as well. I'm on a restricted machine so I can't change my environment variables but I have a java.configuration.rutimes array with both Java 11 and the JDK that I need for my project and when I open "Configure Java Runtime" I only see that one. So then I add a java.home to my project settings and Java 11 disappears and the plugin breaks with the "Java 11 or more recent is required to run..." error.

    I also posted this in issue #1543 and I figured since this is what I'm dealing with I would post it here too.

  3. jjoker0110 commented on Nov 4, 2020

    @jjoker0110

    Just found a working solution: https://devblogs.microsoft.com/java/about-upgrading-to-java-11-for-vs-code-for-java

    Basically the java.home needs to point to java 11 and then in your java.configuration.runtimes array need to ONLY have the runtime you want your project to be in. This is annoying because you can't put the java.configuration.runtimes array in your projects settings.json, only in your machine/remote machine's settings.json

    Hope this helps

  4. testforstephen commented on Dec 18, 2020

    @testforstephen
    Collaborator

    When you use the latest "Java: Configure Java Runtime" command, you can also configure Project JDKs and Java Tooling JDK as well.

    image

    image

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions