I'm trying to set a JDK path and IntelliJ gives this error:
The selected directory is not a valid home for JDK
But I am sure that it is absolutely valid because I can use the java compiler.
javac Main.java
compiles the file correctly.
I am sure that the path is also correct because the command below gives me that path.
/usr/libexec/java_home
prints the path below:
/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
When I choose this path on IntelliJ, it shows the error. I reinstalled the JDK and also tried to choose /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home/bin/
but none of them worked.
Please do not consider this question is a duplicate because I tried all of the solutions offered in other answers.
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.
Set JAVA_HOME: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1. 6.0_02.
From the main menu, select File | Project Structure | Project Settings | Project. If the necessary JDK is already defined in IntelliJ IDEA, select it from the SDK list.
You do not need to install Java to run IntelliJ IDEA because JetBrains Runtime is bundled with the IDE (based on JRE 11). However, to develop Java applications, a standalone JDK is required.
For the latest version of Intellij community edition, check their release notes here : https://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+2018.1+181.5540.7+Release+Notes
Seems there's a bug "Manually provided JDK 10 not accepted in JShell: "JDK version is 8"
Hope it helps.
Thanks.
I had the same issue, but - in my case and I'm pretty confident in your case too - it is not related to the bug presented in the accepted answer. For some reason, IDEA IntelliJ doesn't accept any OpenJDKs. I tried all version from 7 to 9. It worked immediately once I installed the Oracle JDK (version 10 this time).
Also, you might have multiple JDK installed and when running the java command in the terminal - without knowing - you may be actually using a different JDK than the one you think you're using.
Use which java
and then ls -l
the resulted path to see what's behind the symlink.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With