34

Update: Not sure why this is marked as a duplicate. I had already linked to the other post stating that none of the suggestions / answers work for me. In addition, their question seems to be related to an issue using Windows VMs via Mac, which is irrelevant for me.

I am using IntelliJ IDEA 14.0.3. I have selected the 'Java Hello World' sample. When I try and run the program I receive the error: "Error: java: Cannot find JDK '1.8' for module 'Deliverable4'. I have tried every single suggestion from this post intellij - java: Cannot find JDK '1.7' for module but still can't this to work. Any help would be greatly appreciated.

0

6 Answers 6

54

Go to:

File => Project structure

And check: Project, Modules and SDKs tabs:

enter image description here

If at SDKs Java 1.8 Sdk isn't selected just add it.

And press OK.

1
  • Thanks for the help. These were configured correctly at the time of the original post. Cheers. Commented Mar 26, 2015 at 19:11
10

I suddenly started seeing this issue when upgrading my Java SDK from 1.8 to 10.

I went to File > Project Structure > SDKs, JDK home path was in red so I clicked the folder icon to the right of the path.

Even though the Finder window that popped up already had me in the correct directory /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home (maybe it dropped me wherever my newly updated classpath said Java was?), the path that was displayed in red wasn't the same as that path. Instead, it was using the old one, something like /Library/Java/JavaVirtualMachines/jdk-1.8_(???)/Contents/Home. Clicked OK and the JDK home path was updated to the correct directory, clicked Apply/OK and everything was fine after that.

For reference,

IntelliJ IDEA 2018.2.1 (Community Edition) Build #IC-182.3911.36, built on August 6, 2018 JRE: 1.8.0_152-release-1248-b8 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o macOS 10.12.6

5

Updating from IntelliJ version 14.0.3 to 14.1 seemed to fix the problem.

3

If the update solution given above doesn't work for somebody, consider not using the bin directory like the one used in the PATH environment but rather the java root directory. In short instead of:

path_to_java_folder\java\bin\

use:

path_to_java_folder\java\

and everything will work just fine.

0

I had the same problem, so, I had to clean my project again and install it from Maven. enter image description here

0

I had the same problem. And I changed the project JDK, rerun IDEA, maven clean compile install, etc. But it didn't work, until I found the JRE in Run/Debug Configurations is RED!

After I selected current version in JRE , and everything works just fine!

Run/Debug Configurations - JRE

Not the answer you're looking for? Browse other questions tagged or ask your own question.