Skip to content

Update jdk and old workspace still points to the stale JRE system libraries #355

Closed

Description

@testforstephen

Steps to reproduce:

  1. Install jdk1.8.0_131 in windows 10, and set JAVA_HOME and Path environment variables.

  2. Install latest vscode-java extension in vscode, and open a java 8 maven project.

  3. F12 at java.io.PrintStream.println, jump to editor contents/rt.jar/java.io/PrintStream.class.

  4. Install the latest jdk-9.0.1 and update JAVA_HOME and Path environment variables.

  5. Restart vscode window.

  6. F12 at java.io.PrintStream.println, still jump to the stale jre source contents/rt.jar/java.io/PrintStream.class. It's supposed to jump to the java 9 source contents/java.base/java.io/PrintStream.class.

Actually the java language server was launched by the new java 9 jvm, but the workspace cached the old JRE 8 system libraries and user has no way to change the JRE system libraries.

Current workaround is to clean up the vscode local storage directory C:\Users\jinbwan\AppData\Roaming\Code - Insiders\User\workspaceStorage.

Expected:
When vscode-java extension startup, update the workspace jre container to the one under JAVA_HOME silently.
Or provide a command to allow user to update the workspace JRE container.

Activity

  1. ikbalsingh commented on Jan 20, 2018

    @ikbalsingh

    Current Workaround for Ubtuntu (cleared .config/Code/User/workspace) not working.

  2. self-assigned this
    on Jan 20, 2018
  3. snjeza commented on Feb 20, 2018

    @snjeza
    Collaborator

    If there are JDK8 and JDK9 in the workspace, Java LS will configure a project's JRE based on the project settings.
    If you want to use JDK9, you should add:

    <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
            <source>9</source>
            <target>9</target>
        </configuration>
    </plugin>
    

    to your pom.xml

    @fbricon We can remove all JREs except a JRE defined with the java.home property.

  4. fbricon commented on Feb 20, 2018

    @fbricon
    Collaborator

    as a best practice, you should prefer <release> over the <source>+<target> combo, since the compiler will check no unavailable APIs will be leaked during compilation. Only works for Java9+ projects though.

    <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
            <release>9</release>
        </configuration>
    </plugin>

    @snjeza not sure about removing other JREs. You still need to be able to switch between JDK easily, eg. 1.8 -> 9. I need to think about it.

  5. fbricon commented on May 19, 2020

    @fbricon
    Collaborator

    @testforstephen is this still an issue?

  6. 13rac1 commented on Apr 6, 2023

    @13rac1
    • vscode: 1.77.1
    • Extension Pack for Java: v0.25.1
    • Language Support for Java(TM) by Red Hat: v1.16.0
    • Gradle for Java v3.12.7

    Just encountered this issue or a similar issue. Upgraded a project from 11 to 17. Gradle Tasks vscode-gradle worked with 17, but the vscode-java tooling continued to use Java 11. All settings were ignored: https://github.com/redhat-developer/vscode-java#setting-the-jdk The workaround above worked. I deleted the workspace storage and everything was fine:

    rm -rf ~/.config/Code/User/workspaceStorage
    
  7. robstryker commented on Oct 28, 2026

    @robstryker
    Contributor

    Workaround documented and continues to work, as per recent comments. Closing issue.

    Prefer adding explicit project settings, but in worst case, removing the workspace storage also helps.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions