the compiler compliance specified is 1.8 but a jre 18 is used

Viewed 305

VS Code reported the warning that "the compiler compliance specified is 1.8 but a jre 18 is used" and I don't know how to solve it. I'm searching for more information but I can't find anything about this problem, I need help to solve it.

1 Answers

Here are three 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>18</maven.compiler.source>
    <maven.compiler.target>18</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=18
org.eclipse.jdt.core.compiler.compliance=18
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=18
  1. Add the following in settings.json
    "java.jdt.ls.java.home":"your_path_to_jdk18"
Related