Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 200
Andrew Schade Avatar asked May 08 '15 05:05

Andrew Schade


People also ask

How do I fix the selected directory is not a valid home for JDK?

First at all, you need to select the C:\ folder. Then, you select Program Files. After it, you select java, and finally the jdk you downloaded.

What is JDK home directory?

Your home directory for JDK would be "C:\Program Files (x86)\Java\jre1.8.0_91\bin"

How do I point to JDK in IntelliJ?

In the Project Structure dialog Ctrl+Alt+Shift+S , select SDKs. Select the necessary JDK version if you have several JDKs configured, and open the Documentation Path tab on the right. icon and specify the directory with the downloaded documentation package (for example, C:\Users\jetbrains\Desktop\docs\api).

Does IntelliJ IDEA include JDK?

IntelliJ IDEA doesn't come with the JDK, so if you don't have the necessary JDK version, download and install it. Note that some frameworks require their own SDKs in addition to the JDK, for example, Android or Grails.


2 Answers

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.

like image 82
Francesco Borzi Avatar answered Sep 28 '22 12:09

Francesco Borzi


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.

like image 37
vdegenne Avatar answered Sep 28 '22 10:09

vdegenne