I'm trying to set jdk-10.0.1 in my IntelliJ IDEA. the jdk is installed at C:\Program Files\Java\jdk-10.0.1 and when i pick this path i'm getting the “The selected directory is not a valid home for JDK”.
-
What version of IDEA do you have? Versions older than 2017.3 won't work with java 10. – Petr Rastegaev May 18 '18 at 16:41
-
1Possible duplicate of [IntelliJ IDEA "The selected directory is not a valid home for JDK"](https://stackoverflow.com/questions/21713414/intellij-idea-the-selected-directory-is-not-a-valid-home-for-jdk) – TT-- Sep 12 '18 at 01:10
1 Answers
If you are in ubuntu, i found the solution to this problem. If you are in MAC, is similar. The thing is that firstly you must install the jre and jdk.
I have it in my /usr/lib/jvm
Then, after that, you must puth the variable $JAVA_HOME in your $PATH in the ~/.bashrc file at the end. But i found that after adding my jre and my jdk, my IDE didn't detect my jdk. So what i do to solve this in my IDE was:
In your command line:
nano ~/.bashrc
export JAVA_HOME='/usr/lib/jvm/<your-path>'
export PATH=$PATH:$JAVA_HOME/bin
source ~/.bashrc
If no problem was detected and all is fine, just do
java --version
If is detected, next, go to the other step:
=> Open your IDE. In this step, if your IDE doesn't recognize java version or SDK (as in my case), do the following
javac --version
This is where i solved the problem, becouse it looked like i didn't have javac, so I solved it with:
sudo apt install openjdk-<version>-jdk-headless
=> Then open your IDE and select the SDK you have just installed. Its like the IDE doesn't recognize de previus jdks.

- 11
- 2