11

I am trying to get started with IntelliJ IDEA, however I am not able to set the JDK path. which java returns /usr/bin/java, however IDEA is not able to find the specified path. Expanding bin in the tree from within IDEA shows an unending tree of X11. I also tried /usr/share/java, but that gives an error 'specified path not a directory for JDK' How do I set the JDK path?

Anuraag Baishya
  • 211
  • 1
  • 2
  • 6

3 Answers3

7

The error message is quite clear:

specified path not a directory for JDK

/usr/bin/java it is not a directory to JDK is command for running compiled java programs .class files.

For setup JDK in IntelliJ go to Project Structure in section Platform Settings choose SDKs and add path to JDK usually on Ubuntu it installed in /usr/lib/jvm/. After that in section Project Settings choose Project tab and finally select added JDK:

enter image description here

Anton Dozortsev
  • 1,122
  • 10
  • 21
  • usr/lib/jvm doesn't exist on my system – Anuraag Baishya Nov 14 '15 at 06:31
  • 1
    @AnuraagBaishya What way did you used for installing JDK ? And also say me what command `echo $JAVA_HOME` will print. – Anton Dozortsev Nov 14 '15 at 13:25
  • I installed java using webupd8 ppa. Also echo $JAVA_HOME doesn't return anything. The thing is IDEA doesn't work, however Android Studio which is based on IDEA works perfectly. – Anuraag Baishya Nov 14 '15 at 16:53
  • @AnuraagBaishya You have any configuration in `SDKs` (as on screenshot) section in Android Studio ? If so add the same configurations in IntelliJ. – Anton Dozortsev Nov 14 '15 at 17:21
  • @AnuraagBaishya It's very strange that you said about `/usr/lib/jvm` doesn't exist on your system. As I see by this **[guide](http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html)** your JDK should be located in `/usr/lib/jvm/java-8-oracle` folder – Anton Dozortsev Nov 14 '15 at 17:23
  • 2
    You need to download an oracle jdk - unpack tar.gz and point Project SDK to unpacked dir – Kirill Mikhailov Nov 28 '17 at 16:09
  • does it make a difference in using a JDK present in `/usr/lib/jvm/java-8-openjdk-amd64` Or `/opt/java/jdk-10.0.2` folder?. Also,I found `JAVA_HOME` path in my `/etc/environment file`: `JAVA_HOME="/opt/java/jdk-10.0.2/bin" ` and When, I followed the above post sugegstions to set the JAVA_HOME path: `JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::") ` and did `echo $JAVA_HOME` what I get was `/usr/lib/jvm/java-8-openjdk-amd64/jre/` In what ways these two `JAVA_HOME` path are different,what I did wrong?any suggestion on how to fix it.Also,I have no permission to edit `/etc/environment` – Anu Jan 17 '19 at 16:03
6

I'm using Ubuntu 18.04 LTS and fresh IDEA 2019.2.

I have met the same problem and solved it by installing several openjdk packages. "openjdk-8-jdk" alone is not enough.

For OpenJDK 8 (1.8) you need to install:

sudo apt install openjdk-8-demo openjdk-8-doc openjdk-8-jdk openjdk-8-source

For OpenJDK 11:

sudo apt install openjdk-11-demo openjdk-11-doc openjdk-11-jdk openjdk-11-source

Then both SDKs are recognized correctly (choose one of subfolders in /usr/lib/jvm/ folder).

alexb
  • 171
  • 1
  • 2
2

As Kirill Mikhailov pointed out, using oracle jdk instead of the already installed open jdk has solved the issue for me
I'm using Intelij 2017.2 CE

  • Issue was with Linux not finding the correct folder due to some reason, I had Oracle JDK. Also, IntelliJ works equally well with Open JDK. This issue has been resolved long back :) – Anuraag Baishya Jan 04 '18 at 09:30
  • Yes switching to oracle-java-8 solved my issue too. – Dipen Mar 21 '18 at 22:30