IntelliJ IDEA无法启动:无法加载JDK类:com.sun.jdi.Field

huangapple go评论67阅读模式
英文:

IntelliJ IDEA doesn't start: Cannot load a JDK class: com.sun.jdi.Field

问题

当我尝试启动IntelliJ时,弹出一个窗口,上面写着:

无法加载JDK类:com.sun.jdi.Field
请确保您在JDK上运行IDE,而不是JRE。

这真的很奇怪,因为我已经将JAVA_HOMEPATH变量指向了Java 11的JDK。

英文:

When I try to start IntelliJ I get a popup saying

Cannot load a JDK class: com.sun.jdi.Field 
Please ensure you run the IDE on JDK rather than JRE.

It's really strange because I've pointed the JAVA_HOME and PATH variable to the Java 11 JDK.

答案1

得分: 32

这个问题发生在您用其他版本覆盖了默认的 JetBrains Runtime,并且 IDE 将此运行时的位置保存在 CONFIGidea64.exe.jdk 文件中,然后此运行时变得无效(已删除或损坏)或与新的 IDE 版本不兼容。

解决方案是删除 idea64.exe.jdk/idea.exe.jdk 文件,以便 IDE 使用默认捆绑的 JetBrains Runtime(文件名可能因您使用的产品而异,因此通用指南是删除 IDE 配置目录 中的 *.jdk 文件)。

以下是大多数 Windows 用户应删除的文件路径:

c:\Users\<user>\AppData\Roaming\JetBrains\IntelliJIdea2020.1\idea64.exe.jdk

当此文件指向 Java 8 时,此问题会发生,因为 IntelliJ IDEA 不再在 Java 8 上运行,而是需要 Java 11。尽管 Java 11 已经捆绑在其中,但该文件会对其进行覆盖,从而引发问题。

还请检查 此文档,了解其他可能的覆盖 IDE 运行时的方法,并确保没有任何这些方法生效:

IDEA_JDK_64 环境变量也可能会覆盖默认的运行时,您需要取消设置它。

另一个可能的问题是 jbr 子目录中的捆绑运行时已损坏。通过在 IDE_HOME\jbr\bin 内运行 java -version 进行验证。重新安装 IDE 应该会有所帮助。

还可以在 IntelliJ IDEA 论坛的相关讨论 中查看。

此问题正在 YouTrack 上进行调查

英文:

This issue occurs if you override the default JetBrains Runtime with some other version, IDE saves the location of this runtime under CONFIG\idea64.exe.jdk file and then this runtime becomes invalid (removed or corrupted) or incompatible with the new IDE version.

The solution is to delete idea64.exe.jdk/idea.exe.jdk file so that IDE is using the default bundled JetBrains Runtime (the file name could be different depending on the product you are using, so the general guide is to delete *.jdk files in the IDE config directory).

Here is the file that should be deleted for most of the users on Windows:

c:\Users\&lt;user&gt;\AppData\Roaming\JetBrains\IntelliJIdea2020.1\idea64.exe.jdk

The issue occurs when this file points to Java 8 as IntelliJ IDEA no longer runs on Java 8 and is expecting Java 11 instead. Java 11 is already bundled, but this file overrides it, hence the problem.

Please also check this document for the other possible ways to override IDE runtime and make sure none of these is in effect:

IDEA_JDK_64 environment variable may also override the default runtime, you need to unset it.

Another possible issue is that the bundled runtime in jbr subdirectory becomes corrupted. Verify it by running java -version inside IDE_HOME\jbr\bin. Reinstalling IDE should help.

See also a related discussion in IntelliJ IDEA forum.

The issue is being investigated in YouTrack.

答案2

得分: 1

确保您的IntelliJ版本支持在Java 11上运行(不仅仅是用它进行编译)。另外,如果您使用的是Windows并且刚刚定义了JAVA_HOME变量,请重新启动。

英文:

Ensure that your IntelliJ version supports running on Java 11 (not just compiling with it). Additionally, if you're using Windows and just defined the JAVA_HOME variable, reboot.

答案3

得分: 1

从2020.1版本开始,配置文件夹位于%APPDATA%/Roaming/JetBrains/<product><version>文件夹中。

我不得不在该文件夹中删除我的*.jdk文件以便重新配置它。

英文:

from 2020.1 onwards the configuration folder is located in %APPDATA%/Roaming/JetBrains/&lt;product&gt;&lt;version&gt; folder.

I had to delete my *.jdk file in that folder for it to reconfigure itself.

答案4

得分: 0

  • 检查是否在IntelliJ配置文件中未被覆盖:https://www.jetbrains.com/help/idea/switching-boot-jdk.html
  • 作为最后的尝试,尝试通过配置文件进行更改。
英文:

答案5

得分: 0

只需将系统变量JAVA_HOME从:

JAVA_HOME=C:\Program Files\Java\jre

更改为:

JAVA_HOME=C:\Program Files\Java\jdk

在我的情况下正常运行(在Windows上)。

英文:

Just change system variable JAVA_HOME from:

JAVA_HOME=C:\Program Files\Java\jre

to:

JAVA_HOME=C:\Program Files\Java\jdk

Works for me like charm (on Windows).

huangapple
  • 本文由 发表于 2020年4月11日 01:16:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/61145290.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定