I created a new maven project in VSCode. When I try to run a file, I get this error
The compiler compliance specified is 1.7 but a JRE 13 is used
but there are no instructions on how to fix the error. What do I do?
These are the VSC plugins I have installed:
To solve this problem, you have to update manually the pom.xml file. Everything you have to do is explained in the doc, section "Java 9 or later". Here are the steps to follow.
The default pom.xml file provide theses informations:
Old version - pom.xml
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
As you can see, Maven uses an outdated plugin to be used with maven.compiler.source for Java 1.7. Here you want to update the plugin an specify the use of Java 13. Modify pom.xml like so:
New solution version - pom.xml
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>13</maven.compiler.release>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Now don't forget to update VSCode configutation by right-clicking on the pom.xml file then click on Update Project Configuration
or do Alt+Shift+U
and wait for the change to apply.
Normally, the PROBLEMS section should be No problems have been detected in the workspace so far.
my problem was similar but with JDK11 and JDK14
In my case, I changed the version in the pom.xml, like @Onyr said, but the problem kept popping up. To fix it I followed these steps:
Crtl + Shift + P
. This will show a popup when you can write>Configure Java runtime
(Make sure not to delete the character >
)As you can see, the current path point to JDK14, but I want to use JDK11
User Setting
(Blue link in "Type" column)Edit in settings.json
"java.home"
and change the path to the JDK you want to useFor example, in my case, this line changed from:
"java.home": "C:\\Program Files\\Java\\jdk-14.0.2",
To:
"java.home": "C:\\Program Files\\Java\\jdk-11.0.8",
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With