Selected directory is not a valid home for JDK - Intellij IDEA on Ubuntu

I had the same problem, in my case I wasn't able to select any of the "openjdk" directories under /usr/lib/jvm/, I solved with:

sudo apt-get install openjdk-8-jdk

When restarting intellij it will find the path to the jdk automatically.


For the ones who run into this problem even though you select the right directory under /usr/lib/jvm, there is something you should know : The directories under /usr/lib/jvm are created when your system installs the minimum set of java tools. But it doesn't mean you have the development files available. You need to install the development files :

sudo apt-get install java-1.8.0-openjdk-devel

After installing this package, try to select the directory again and it should work.