14

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.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
Cerus
  • 141
  • 1
  • 11
  • Kind pf tricky thing to debug remotely but 1) show us your JAVA_HOME variable. 2) Check if it is not overriden in IntelliJ config file https://www.jetbrains.com/help/idea/switching-boot-jdk.html 3) as a last resort, try changing it via config file – Lesiak Apr 10 '20 at 17:54
  • @Lesiak Changing the JDK in the .jdk file helped! Thanks! – Cerus Apr 10 '20 at 18:03
  • Download IntelliJ _with_ a JDK. This should work out of the box – Thorbjørn Ravn Andersen Apr 10 '20 at 18:49
  • @ThorbjørnRavnAndersen not if was changed per https://intellij-support.jetbrains.com/hc/articles/206544879 and the custom runtime location became invalid, see my answer for more details. – CrazyCoder Apr 10 '20 at 18:50
  • @CrazyCoder True. Kudos to the team for making a "brings own jvm" distribution - it makes things much easier! – Thorbjørn Ravn Andersen Apr 10 '20 at 18:59

5 Answers5

32

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.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
1

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.

  • I'm using the latest IntelliJ IDEA Ultimate version which should support Java 11. A reboot didn't fix the problem unfortunately. – Cerus Apr 10 '20 at 17:35
1

from 2020.1 onwards the configuration folder is located in %APPDATA%/Roaming/JetBrains/<product><version> folder.

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

coderatchet
  • 8,120
  • 17
  • 69
  • 125
0
Lesiak
  • 22,088
  • 2
  • 41
  • 65
0

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).

Tapa Save
  • 4,769
  • 5
  • 32
  • 54