JDK path in IntelliJ IDEA on Windows 10 Enterprise

Viewed 2796

I have the JDK path in IntelliJ IDEA set to C:\Program Files\Java\jdk8 , nevertheless, when I go to the file system I am not able to find this path, and I show all the hidden files !

enter image description here

I can also access to the folder from the IntelliJ IDEA terminal, but not from the command line:

enter image description here

C:\>cd "C:\Program Files\Java"
The system cannot find the path specified.

C:\>cd C:\Program Files\Java
The system cannot find the path specified.
5 Answers

The root cause of such a situation is some wrong path set in the PATH environment variable. Let's assume echo %PATH% prints the following:

C:\Path X;C:\Path Y;D:\Path Z;

However, when you go to the environment variables window, you see a longer path. It means that the path after D:\Path Z is wrong and therefore the next strings in the PATH variable will throw this error.

To troubleshoot the problem, echo %PATH% and see if it prints your Java path in the output. If not, now you know how to deal with it.

Restart the IntelliJ IDEA to check whether it's displaying the same in SDK tab.

If it is still showing the same, then, it may be a bug of the software. Generally, it should not show as it's not installed.

Note: Now, as you know that Java 8 is not installed on your system but IDE is showing that it is installed. You can do one thing :

Create a small Java project with sample classes, then try to compile it. If it is not compiling and giving error, then you will be assured that it's not installed.

This will mean that IDE is not updating itself and it's keeping the old record.

Last option, install JDK 1.8 and reinstall Intellij IDEA.

I would advise you to do the following in your command prompt:

C:\Program Files>dir | findstr /I "Java"

You should have something like this (mind the "<DIR>"):

13/11/2019  22:30    <DIR>          Java

It's possible that you have a symlink, junction or something like that, messing up your system. Well, it's not messing up your system, but maybe your application can't handle it. In that case, you might redefine your variable on the directory your symlink or junction is referring to.

Set the path by doing the follow

This-PC -> System properties-> advanced system settings -> environment variable

Then add the path to your java bin folder like this C://program files/Java/jdk1.8/bin

Apply/save

Then go back to CMD and type javac or java

Related