skip to Main Content

In VS Code I want to run a particular project with an older JRE (Java. 1.8) than the one VS Code and its language server uses (Java 17).

How can I change the JRE for a project to an older JRE? I tried righting click on the JRE in the Java Projects view:

JRE in VS Code

However, with this I could not get to a related setting.

2

Answers


  1. There are three step in your project.
    First you have to download a extension named Extension Pack for Java.
    Second you have to edit in settings.json of Java.The path is Settings/Users/Java.And add the configuration in it.

    "java.configuration.runtimes": [
            {
                name:"JavaSE-1.8",
                path:"D:\develop\jdk\corretto-1.8.0_362",
                "default": true
            },
            {
                name:"Javase-11",
                path:"D:\develop\jdk\corretto-11.0.19"
            }
        ]
    

    Then you must check the jdk version on your maven file or gradle file is the current version you wanted.
    The follow is a picture of the operation.The java extension only occure when you installed the Extension Pack for Java

    enter image description here

    Login or Signup to reply.
  2. To see which JDKs are used for your projects, you can trigger the command Java: Configure Java Runtime in Command Palette (Ctrl+Shift+P). This command opens a view displaying the runtime information for your projects:

    enter image description here

    The Java extension requires a minimum version of Java 17 to activate the java language server, use the following setting

        "java.jdt.ls.java.home": "E:\Program Files\Java\jdk-17.0.5",
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search