Home > Software engineering >  How set specific JRE version on Vscode
How set specific JRE version on Vscode

Time:07-25

I'm trying to build a AEM project with maven, but when opening the project with vscode the error The compiler compliance specified is 1.8 but a JRE 11 is used is show.

I tried configuring the java runtime pressing ctrl shift p, but its shows that i'm only using the 1.8 versions enter image description here enter image description here

How can I set vscode to use the right JRE version?

CodePudding user response:

You can add JDK installations via the setting: java.configuration.runtimes

e.g.

"java.configuration.runtimes": [
        {
            "name": "JavaSE-1.8",
            "path": "C:\\Program Files\\AdoptOpenJDK\\jdk-8.0.302.8-hotspot",
        },
        {
            "name": "JavaSE-11",
            "path": "C:\\Program Files\\AdoptOpenJDK\\jdk-11.0.10.9-hotspot"
        }
    ]

CodePudding user response:

Here are two modification methods:

  1. Please set the pom.xml file for the maven project
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
  </properties>
  1. Modify the .settings\org.eclipse.jdt.core.prefs file under the Java project
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=enabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=11
  • Related