[英]IntelliJ 2021.2.2 gives error 'java: error: invalid source release: 18' when compiling program
I've looked trough many answers here on so but haven't found anything helpful.我在这里看了很多答案,但没有发现任何有用的东西。 I am using java version 16.0.1 My program doesn't use maven or gradle.
我正在使用 java 版本 16.0.1 我的程序不使用 maven 或 gradle。 The program worked fine until I updated my ij earlier today.
该程序运行良好,直到我今天早些时候更新了我的 ij。
Full error:完整错误:
Executing pre-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Running 'before' tasks
Checking sources
Parsing java... [Adexo]
java: error: invalid source release: 18
Checking dependencies... [Adexo]
Dependency analysis found 0 affected files
Errors occurred while compiling module 'Adexo'
javac 11 was used to compile java sources
Finished, saving caches...
Module 'Adexo' was fully rebuilt due to project configuration/dependencies changes
Compilation failed: errors: 1; warnings: 0
Executing post-compile tasks...
Loading Ant configuration...
Running Ant tasks...
Synchronizing output directories...
30.9.2021 22:34 - Build completed with 1 error and 0 warnings in 3 sec, 279 ms
Here are the files from.idea and the.iml file: https://1drv.ms/u/s?AoGu278qdPOWgm-D3ns61-gqA4Ts?e=OWg0NB以下是来自.idea 和.iml 文件的文件: https://1drv.ms/u/s?AoGu278qdPOWgm-D3ns61-gqA4Ts?e=OWg0NB
Please tell if you need any more information (:请告诉您是否需要更多信息(:
.idea/misc.xml
has incorrect language level specified for some reason ( JDK_X
): .idea/misc.xml
由于某种原因指定了不正确的语言级别( JDK_X
):
<component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="16" project-jdk-type="JavaSDK">
Close the project, change languageLevel
to 16
and see if it helps.关闭项目,将
languageLevel
级别更改为16
,看看是否有帮助。
There was a related bug reported , but it should be fixed in IntelliJ IDEA 2020.2 and later versions.报告了一个相关的错误,但它应该在 IntelliJ IDEA 2020.2 及更高版本中修复。 Probably a regression.
应该是回归吧。
In my case it was the build.gradle
file which at line sourceCompatibility = '18
had 18. I changed it to 11 and now I can build the project.在我的情况下,它是
build.gradle
文件,在sourceCompatibility = '18
'18 行有 18。我将其更改为 11,现在我可以构建项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.