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
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:
- 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>
- 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