I'm creating this question only because the duplicate questions I found were marked with Windows and Ubuntu respectively, whereas I am experiencing this issue on macOS
I have IntelliJ Ultimate 2017.2 installed, with JDK 8 added, and want to add JDK 10. After downloading and installing Oracle's JDK 10, and attempting to add /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
as a new JDK to IntelliJ, I got the error message
The selected directory is not a valid home for JDK
despite the fact that the path and file permissions of this JDK 10 directory were seemingly all aligned with the JDK 8 ones.
It turned out that upgrading to the newest IntelliJ IDEA version was (for some reason) what was required. After installing IDEA 2018.1, I was able to add JDK 10 without issue.