IntelliJ IDEA gives “The selected directory is not a valid home for JDK” error even it is a valid JDK

For the latest version of Intellij community edition, check their release notes here : https://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+2018.1+181.5540.7+Release+Notes

Seems there's a bug "Manually provided JDK 10 not accepted in JShell: "JDK version is 8"

Hope it helps.

Thanks.


I had the same issue, but - in my case and I'm pretty confident in your case too - it is not related to the bug presented in the accepted answer. For some reason, IDEA IntelliJ doesn't accept any OpenJDKs. I tried all version from 7 to 9. It worked immediately once I installed the Oracle JDK (version 10 this time).

Also, you might have multiple JDK installed and when running the java command in the terminal - without knowing - you may be actually using a different JDK than the one you think you're using.

Use which java and then ls -l the resulted path to see what's behind the symlink.


Make sure your version of IntelliJ is newer then the JDK! (or better go to the newest version of IntelliJ)