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

Andrew Schade picture Andrew Schade · May 8, 2015 · Viewed 68.1k times · Source

After installing Intellij Idea 14, with OracleJDK 1.8 u25 (64 bit) on my 14.04 Ubuntu system, I cannot configure the Java SDK to use any JDK. When I navigate to Module Settings->SDK and click configure SDK, the add button, and then select /usr/java/jdk1.8.0_25 in the dialog, I get an error popup stating that "The selected directory is not a valid home for JDK."

I've checked the contents of the directory, which contains a bin folder with both java and javac inside, a lib folder and a jre folder.

I've tried selecting each of those in turn, to no avail, which I expected.

Answer

Francesco Borzi picture Francesco Borzi · Aug 7, 2017

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.