错误:Java:无效的目标版本:11-IntelliJ IDEA [英] Error: Java: invalid target release: 11 - IntelliJ IDEA
问题描述
我正在尝试构建使用Java 8构建的应用程序,现在它已升级到Java11.我安装了我的 Windows计算机中的oracle文章,我使用的是 IntelliJ IDEA 2017 strong>作为我的IDE.
I am trying to build an application which was built using java 8, now it's upgraded to java 11. I installed Java 11 using an oracle article in my windows machine and I use IntelliJ IDEA 2017 as my IDE.
我更改了系统环境变量并设置了
I changed my system environment variables and set the
JAVA_HOME to C:\Program Files\Java\jdk-11.0.1
并将其添加到Path
变量中.
C:\>java -version
java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)
当我在IntelliJ中构建应用程序时,这就是我得到的:
When I build my application in IntelliJ, this is what I get:
Information:java: Errors occurred while compiling module 'test-domain_main'
Information: javac 1.8.0_171 was used to compile java sources
Information:1/10/2019 4:21 PM - Compilation completed with 1 error and 0 warnings in 1s 199ms
Error:java: invalid target release: 11
这是我到目前为止尝试过的:
This is what I've tried so far:
-
我将
.idea/compiler.xml
目标值从8更改为11,但这无济于事.此外,还要验证settings > Build, Execution, Deployment > Compiler > Java Compiler
中的Target bytecode version
并将我的所有模块都设置为11.
I changed
.idea/compiler.xml
target values from 8 to 11 but that didn't help. Also, verified theTarget bytecode version
insettings > Build, Execution, Deployment > Compiler > Java Compiler
and all my modules are set to 11.
转到file > Project Structure > SDKs *(currently I have 1.7 and 1.7 listed)* > Add new SDK > JDK >
此后,我选择了C:\Program Files\Java\jdk-11.0.1
,但出现错误,提示所选目录不是JDK的有效主目录"
Went to file > Project Structure > SDKs *(currently I have 1.7 and 1.7 listed)* > Add new SDK > JDK >
After that, I selected C:\Program Files\Java\jdk-11.0.1
But it errors out with "The selected directory is not a valid home for JDK"
我不确定是否安装了错误的JDK 11,因为在我的C:\Program Files\Java\
中,我看到了1.7
和1.8
的单独的JDK和JRE文件夹,但是只有11.0.1
的JDK文件夹
I am not sure if I installed the wrong JDK 11, because in my C:\Program Files\Java\
, I see separate JDK and JRE folders for 1.7
and 1.8
but only JDK folder for 11.0.1
还是我需要更改的其他内容?
Or is it something else I need to change?
推荐答案
请更新到IntelliJ IDEA 2018.x获得Java 11支持.您的IntelliJ IDEA版本是在Java 11之前发布的,并且不支持该Java版本.
Please update to IntelliJ IDEA 2018.x to get Java 11 support. Your IntelliJ IDEA version was released before Java 11 and doesn't support this Java version.
这篇关于错误:Java:无效的目标版本:11-IntelliJ IDEA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!