Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ - java: Cannot find JDK '1.8'

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.

like image 734
Justin Papez Avatar asked Mar 26 '15 18:03

Justin Papez


People also ask

Is JDK 1.8 is same as Java 8?

8 and java 8?? http://www.oracle.com/technetwork/java/javase/jdk8-naming-2157130.html Java SE Development Kit 8, also known as JDK 8, has the version number 1.8. In short – 8 is product version number and 1.8 is the developer version number (or internal version number). The product is the same, JDK 8, anyways.

Where is my JDK in IntelliJ?

From the main menu, select File | Project Structure | Project Settings | Project. If the necessary JDK is already defined in IntelliJ IDEA, select it from the SDK list.


2 Answers

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.

like image 107
catch23 Avatar answered Sep 23 '22 19:09

catch23


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

like image 39
mz496 Avatar answered Sep 21 '22 19:09

mz496