IntelliJ:错误:java:错误:不支持发布版本 5 [英] IntelliJ: Error:java: error: release version 5 not supported
问题描述
我使用的是 IntelliJ IDEA Ultimate 2019.3.1.每当我尝试启动任何简单的 Java Maven 项目(甚至可能是一个简单的 Hello World)时,我都会收到以下错误:
Error:java: error: release version 5 not supported
通过终端运行 java --version
我得到以下输出:
openjdk 11.0.5 2019-10-15OpenJDK 运行时环境(构建 11.0.5+10-post-Ubuntu-0ubuntu1.1)OpenJDK 64-Bit Server VM(build 11.0.5+10-post-Ubuntu-0ubuntu1.1,混合模式,共享)
通过终端运行 javac --version
我得到以下输出:
javac 11.0.5
转到 Java 编译器的设置(如建议的
我尝试将目标字节码版本"编辑为 1.8,但出现以下错误:
Error:(1, 26) java: 包 javafx.application 不存在错误:(2, 20) java: 包 javafx.stage 不存在错误:(4, 27) java: 找不到符号符号:类应用错误:(12, 23) java: 找不到符号符号:类舞台位置:类 Main错误:(7, 9) java: 找不到符号符号:方法启动(java.lang.String[])位置:类 Main错误:(11, 5) java: 方法没有覆盖或实现来自超类型的方法
将其更改为版本 1.11 我反而收到此错误:
错误:java:不再支持源选项 5.使用 6 或更高版本.
您认为问题出在哪里?我该如何解决?
参见 https://stackoverflow.com/a/12900859/104891.
首先在pom.xml
中像这样设置language level
/release versions
:
<maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target></属性>
Maven 将默认设置为 1.5 否则.如果您还没有,您还需要包含 maven-compiler-plugin
:
<依赖><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version></依赖>
另外,尝试在每个地方更改 Java 版本:
文件 -> 项目结构 -> 项目 -> 项目 SDK -> 11.
文件 -> 项目结构 -> 项目 -> 项目语言级别 -> 11.
文件 -> 项目结构 -> 项目 -> 模块 -> -> 源文件 --> 11
在项目中 -> ctrl + alt + s -> 构建、执行、部署 -> 编译器 -> Java 编译器 -> 项目字节码版本 -> 11
在项目中 -> ctrl + alt + s -> 构建、执行、部署 -> 编译器 -> Java 编译器 -> 模块-> 1.11.
I'm using IntelliJ IDEA Ultimate 2019.3.1. Whenever I try to start any simple Java Maven project (may it be even a simple Hello World) I get the following error:
Error:java: error: release version 5 not supported
Running java --version
by terminal I get the following output:
openjdk 11.0.5 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-post-Ubuntu-0ubuntu1.1)
OpenJDK 64-Bit Server VM (build 11.0.5+10-post-Ubuntu-0ubuntu1.1, mixed mode, sharing)
Running javac --version
by terminal I get the following output:
javac 11.0.5
Going to the Settings of the Java Compiler ( as suggested here ) I see this:
I tried editing the "Target bytecode version" to 1.8 but I get the following errors:
Error:(1, 26) java: package javafx.application does not exist
Error:(2, 20) java: package javafx.stage does not exist
Error:(4, 27) java: cannot find symbol
symbol: class Application
Error:(12, 23) java: cannot find symbol
symbol: class Stage
location: class Main
Error:(7, 9) java: cannot find symbol
symbol: method launch(java.lang.String[])
location: class Main
Error:(11, 5) java: method does not override or implement a method from a supertype
Changing it to version 1.11 I get this error instead:
Error:java: Source option 5 is no longer supported. Use 6 or later.
What do you think is the problem? How may I solve it?
See https://stackoverflow.com/a/12900859/104891.
First of all, set the language level
/release versions
in pom.xml
like that:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Maven sets the default to 1.5 otherwise. You will also need to include the maven-compiler-plugin
if you haven't already:
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</dependency>
Also, try to change the Java version in each of these places:
File -> Project structure -> Project -> Project SDK -> 11.
File -> Project structure -> Project -> Project language level -> 11.
File -> Project structure -> Project -> Modules -> -> Sources --> 11
In project -> ctrl + alt + s -> Build, Execution, Deployment -> Compiler -> Java Compiler -> Project bytecode version -> 11
In project -> ctrl + alt + s -> Build, Execution, Deployment -> Compiler -> Java Compiler -> Module -> 1.11.
这篇关于IntelliJ:错误:java:错误:不支持发布版本 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!