Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 819
Cerus Avatar asked Apr 10 '20 17:04

Cerus


People also ask

Do I need to install JDK for IntelliJ IDEA?

You do not need to install Java to run IntelliJ IDEA because JetBrains Runtime is bundled with the IDE (based on JRE 11). However, to develop Java applications, a standalone JDK is required.

How do I point to JDK in IntelliJ?

If the necessary JDK is already defined in IntelliJ IDEA, select it from the SDK list. If the JDK is installed on your computer, but not defined in the IDE, select Add SDK | JDK, and specify the path to the JDK home directory (for example, /Library/Java/JavaVirtualMachines/jdk-12.0. 1. jdk).

Does IntelliJ support JDK 17?

JetBrains has released IntelliJ IDEA 2022.2 featuring support for Java 17 and the latest languages and frameworks such as Scala, Kotlin, Spring 6 and Spring Boot 3.


2 Answers

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\<user>\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.

like image 61
CrazyCoder Avatar answered Sep 22 '22 17:09

CrazyCoder


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.

like image 22
Jorge Yanes Diez Avatar answered Sep 21 '22 17:09

Jorge Yanes Diez