简体   繁体   English

IntelliJ 2021.2.2 在编译程序时给出错误“java:错误:无效的源版本:18”

[英]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

项目模块Java 编译器

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.

相关问题 连续获取java:无效源版本:编译时出错1.9 - Continuously getting the java: invalid source release: 1.9 error when compiling intellij 想法 - 错误:java:源代码版本 1.9 无效 - intellij idea - Error: java: invalid source release 1.9 错误:java:无效的源版本:Intellij 中的 8。 这是什么意思? - Error:java: invalid source release: 8 in Intellij. What does it mean? IntelliJ:致命错误编译:无效的目标版本:1.8 - IntelliJ: Fatal error compiling: invalid target release: 1.8 Intellij maven 项目编译致命错误:无效标志:--release - Intellij maven project Fatal error compiling: invalid flag: --release 错误:java:错误:源代码版本无效:13 使用带有 IntelliJ 的 JDK12 - Error:java: error: invalid source release: 13 using JDK12 with IntelliJ Java zip 文件来自 Netbeans:错误无效的目标版本 18 - Java zip file from Netbeans: Error Invalid target release 18 编译 Java 头文件时出现 Intellij + Bazel 错误 - Intellij + Bazel Error when compiling Java headers 错误:Java:无效的目标版本:11 - IntelliJ IDEA - Error: Java: invalid target release: 11 - IntelliJ IDEA 从Java 9降级为Java 8时,为什么仍会收到无效的源代码发布错误? - Why do I still get an invalid source release error when downgrading from Java 9 to Java 8?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM