简体   繁体   中英

VSCode + maven project wrong java version

JAVA_HOME:

PS C:\Users\Himanshu\Desktop\work\demo> $Env:JAVA_HOME
C:\Program Files\Java\jdk-17.0.1

Java version mismatch

Please see the above image. Why is it displaying Java 1.6 and in brackets pointing to java 17? This is also not compiling lambda functions.

Looks like a bug in VSCode.

EDIT: I switched to Intellij Idea. And it worked smoothly. It is using the JAVA_HOME. :)

Removing the following from pom.xml of my project fixed it:

<properties>
  <maven.compiler.source>17</maven.compiler.source>
  <maven.compiler.target>17</maven.compiler.target>
</properties>

Ctrl+Shift+P , type (with auto-completion): "Java: Configure Runtime" (per project;)

VS 代码截图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM