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?
- 221
3 Answers
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:
- 1,132
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).
- 181
-
Since Oracle JDK is no longer free to use like it used to, not to mention old answers are already old, this answer is very helpful now. – matanox Aug 07 '19 at 12:23
-
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
- 121
-
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
-
echo $JAVA_HOMEwill print. – Anton Dozortsev Nov 14 '15 at 13:25SDKs(as on screenshot) section in Android Studio ? If so add the same configurations in IntelliJ. – Anton Dozortsev Nov 14 '15 at 17:21/usr/lib/jvmdoesn't exist on your system. As I see by this guide your JDK should be located in/usr/lib/jvm/java-8-oraclefolder – Anton Dozortsev Nov 14 '15 at 17:23/usr/lib/jvm/java-8-openjdk-amd64Or/opt/java/jdk-10.0.2folder?. Also,I foundJAVA_HOMEpath 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 didecho $JAVA_HOMEwhat I get was/usr/lib/jvm/java-8-openjdk-amd64/jre/In what ways these twoJAVA_HOMEpath 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