不受支持的 Java 版本:无法在 Java 1.7 下启动:需要 Java 1.8 或更高版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34921899/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 16:07:22  来源:igfitidea点击:

Unsupported Java Version: Cannot start under Java 1.7: Java 1.8 or later is required

javawindowsintellij-idea

提问by Christopher Rucinski

I just updated to IntelliJ IDEA 16which comes with Java JDK 1.8. Fyi, I had downloaded Java JDK 1.8 a long time ago.

我刚刚更新到IntelliJ IDEA 16其自带的Java JDK 1.8。仅供参考,我很久以前就下载了 Java JDK 1.8。

I tried to run my plugin that I am developing, and I cannot even do that, I get the following error message (slightly condensed)

我试图运行我正在开发的插件,但我什至不能这样做,我收到以下错误消息(略有压缩)

"C:\Program Files\Java\jdk1.7.0_45\bin\java" -Xmx512m -Xms256m -XX:MaxPermSize=250m -ea "-Xbootclasspath/a:C:/Program Files (x86)/JetBrains/IntelliJ IDEA Community Edition 144.3143.6\lib\boot.jar" -Didea.config.path=C:\Users\Christopher.IdeaIC14\system\plugins-sandbox\config - ... -Dfile.encoding=windows-1252 -classpath "C:\Program Files\Java\jdk1.7.0_45\lib\tools.jar; ... ;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 144.3143.6\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain com.intellij.idea.Main

Unsupported Java Version: Cannot start under Java 1.7.0_45-b18: Java 1.8 or later is required.

"C:\Program Files\Java\jdk1.7.0_45\bin\java" -Xmx512m -Xms256m -XX:MaxPermSize=250m -ea "-Xbootclasspath/a:C:/Program Files (x86)/JetBrains/IntelliJ IDEA 社区版本 144.3143.6\lib\boot.jar" -Didea.config.path=C:\Users\Christopher.IdeaIC14\system\plugins-sandbox\config - ... -Dfile.encoding=windows-1252 -classpath "C :\Program Files\Java\jdk1.7.0_45\lib\tools.jar; ... ;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 144.3143.6\lib\idea_rt.jar" com.intellij .rt.execution.application.AppMain com.intellij.idea.Main

不受支持的 Java 版本:无法在 Java 1.7.0_45-b18 下启动:需要 Java 1.8 或更高版本。

So, I clearly know what the problem is; however, I cannot seem to figure out where the location to fix this is.

所以,我清楚地知道问题是什么;但是,我似乎无法弄清楚修复此问题的位置在哪里。

I have tried a lot of things so far; most involve using the search boxin Settingsand switching whatever I could to version 1.8. Also, I had updated my Environment Variablefor Java from 1.6 to 1.8

到目前为止,我已经尝试了很多东西;大部分涉及使用该搜索框Settings和交换任何我能到1.8版本。另外,我已经将我Environment Variable的 Java 从 1.6更新到 1.8

With all of these changes, nothing is working! So how do I go about fixing this seemingly simple issue?

有了所有这些变化,什么都不起作用!那么我该如何解决这个看似简单的问题呢?

回答by OttavioMonzione

Double check that your JAVA_HOMEpoints to the correct 1.8 Installation and make sure that in the PATHenv there is no reference to "C:\Program Files\Java\jdk1.7.0_45\bin". Try to print your JAVA_HOME/PATHfrom the Console and see what the output is. If your changes are not reflected logout and then login again.

仔细检查您的JAVA_HOME 是否指向正确的 1.8 安装,并确保在PATH 环境中没有对“C:\Program Files\Java\jdk1.7.0_45\bin”的引用。尝试从控制台打印您的 JAVA_HOME/PATH并查看输出是什么。如果您的更改没有反映出来,请注销然后再次登录。

回答by Leet-Falcon

Set IDEA_JDK(or IDEA_JDK_64) environment variable.
Check Selecting the JDK version the IDE will run under

设置IDEA_JDK(或IDEA_JDK_64)环境变量。
检查选择 IDE 将在其下运行的 JDK 版本

回答by jwenting

IntelliJ 16 REQUIRES Java 8 to run, it won't run under Java 7. It's compiled to Java 8 classes so it can't ever be run on an older JVM.
This is well and clearly mentioned in the documentation.

So if you have your system JVM be an older one, it will fail to start unless you coerce it into using a non-default JVM.
Possibly you have some java related executables left over in your Windows/System32 directory, where some older Java installers would drop them. Delete these by hand from the file system and see what happens.

IntelliJ 16 需要 Java 8 才能运行,它不能在 Java 7 下运行。它被编译为 Java 8 类,因此它永远不能在旧的 JVM 上运行。
文档中清楚地提到了这一点。

因此,如果您的系统 JVM 较旧,除非您强制它使用非默认 JVM,否则它将无法启动。
可能您的 Windows/System32 目录中遗留了一些与 Java 相关的可执行文件,一些较旧的 Java 安装程序会在其中删除它们。从文件系统中手动删除这些,看看会发生什么。

回答by Nate

In case anyone arrives here and hasn't had any luck with the other solutions, try this. I'm using PhpStorm under OSX, but the steps are probably applicable to JetBrains' other IDEs too:

如果有人到达这里并且对其他解决方案没有任何运气,请尝试此操作。我在 OSX 下使用 PhpStorm,但这些步骤可能也适用于 JetBrains 的其他 IDE:

  1. Navigate to your IDE's config folder (see this articleto learn how to find this folder's location).
  2. Open the idea.propetiesfile.
  3. If a JVMVersionattribute exists, delete that entire entry. If it doesn't exist, then this probably won't be of much help!
  4. Save the file.
  5. Launch your IDE.
  1. 导航到 IDE 的 config 文件夹(请参阅本文以了解如何查找此文件夹的位置)。
  2. 打开idea.propeties文件。
  3. 如果JVMVersion属性存在,则删除整个条目。如果它不存在,那么这可能不会有太大帮助!
  4. 保存文件。
  5. 启动您的 IDE。

回答by Srujan Kumar Gulla

TL;DR--> Set JAVA_HOMEto C:\Program Files\Java\jdk1.8.0_51

TL;DR--> 将JAVA_HOME 设置C:\Program Files\Java\jdk1.8.0_51

Java 8 is required to run IntelliJ IDEA starting from version 16 on all the supported platforms.

从版本 16 开始,Java 8 需要在所有支持的平台上运行 IntelliJ IDEA。

The actual JDK versionused by the IDE can be verified in Help | About dialog(open any project to access the menu).

实际的JDK版本IDE使用中可以验证帮助| 关于对话框(打开任何项目以访问菜单)。

idea64.exe uses this JDK search in the following sequence:

IDEA_JDK_64 environment variable
..\jre64 directory
system Registry
JDK_HOME environment variable
JAVA_HOME environment variable

回答by Pierre-Luc Paour

Just in case this page needs one more recommendation, I fixed the problem in my case by going to the IDE's config folder (as @Nate puts it, see herefor how to locate it), and deleting the idea.jdkfile (which held a reference to a 1.6 VM).

以防万一此页面需要更多推荐,我通过转到 IDE 的配置文件夹(如@Nate 所说,请参阅此处了解如何找到它)并删除idea.jdk文件(其中包含对1.6 虚拟机)。

回答by Andreas DM

Under Arch Linux you can simply set java 8 as default (you must have it installed):

在 Arch Linux 下,您可以简单地将 java 8 设置为默认值(您必须安装它):

$ sudo archlinux-java set java-8-openjdk

回答by ccpizza

Apart from setting the correct Java version for the global, per project and per module SDK, for the Java Compiler, and for the language level, you also must set the Target bytecode versionboth for the project and(if you use maven) for each maven module.

除了为全局、每个项目和每个模块 SDK、Java 编译器和语言级别设置正确的 Java 版本之外,您还必须为每个项目(如果您使用 maven)设置目标字节码版本Maven 模块。

Often the project bytecode version is correct but the module bytecode version is lower, i.e. 1.5.

通常项目字节码版本是正确的,但模块字节码版本较低,即 1.5。

Intellij Idea: target bytecode version for maven module

Intellij Idea:maven 模块的目标字节码版本

The per-module bytecode version is not displayedwhen opening the defaultpreferences via File> Other Settings> Default Settings. You must edit the current preferenceseither via a shortcut (i.e. ?+,) or from the main menu as shown below (for mac):

通过File> Other Settings> Default Settings打开默认首选项时,不会显示每个模块的字节码版本。您必须通过快捷方式(即+ )或从主菜单编辑当前首选项,如下所示(对于 Mac):?,

Intellij Idea current preferences

Intellij Idea current preferences

回答by Fran Matsusaka

I had the same problem. All paths pointing to java jdk 8, but still throwing the error. I was able to run Android Studio by running the "studio64.exe" instead "studio.exe" in the bin folder

我有同样的问题。所有路径都指向 java jdk 8,但仍然抛出错误。我能够通过在 bin 文件夹中运行“studio64.exe”而不是“studio.exe”来运行 Android Studio

回答by Israelm

Just set JAVA_HOME system variable to your JDK 8:

只需将 JAVA_HOME 系统变量设置为您的 JDK 8:

enter image description here

enter image description here