Perfect solution for IntelliJ idea error “CreateProcess error = 2, system cannot find the specified file”

I. Background of the problem
The blogger was using Intellij IDEA normally, but Intellij IDEA suddenly sounded wrong for unknown reasons. The error hints were as follows:

Error:Cannot run program “F:\WINDOWS Application Installation \ JRE \bin\ Java “(in directory “C:\Users\ Li Junde \.IntelliJIdea2018.1\ System \ Compile-Server “): CreateProcess Error =2, the system could not find the specified file.


Ii. Problem analysis
By observing the Intellij IDEA error, we know that it was caused by a failure to find the correct installation path for the JDK(Java Development Kit). There are many reasons why Intellij IDEA might not find the JDK: Maybe you accidentally removed it; Or if you install the JDK in a path with Chinese characters, Intellij IDEA does not recognize paths with Chinese characters; Or maybe you accidentally configured the WRONG ENVIRONMENT variable for the JDK on your computer.
The wrong solution
1. Make sure we have the JDK installed on our computer
In 2019, the new version of the JDK(also known as Java) already has the JDK and JRE bundled in it, so installing the JDK is equivalent to installing the JDK and JRE.
Press and hold Windows+R on the computer keyboard, pops out and run program, enter CMD and to confirm. enter Java --version in the black box console to view the Java version number.

If your computer pops up a prompt like the one above (describing the Java version number, release date, etc.), then your computer has the JDK installed correctly, and we go straight to the next step. Otherwise, it means that your computer did not properly install the JDK, you still have to search the latest version of Java in 2019 Java10 and above Java installation tutorial, the bloggers do not recommend small white users to install the old version of Java, the old version of Java needs to install the Java JDK and JRE, also need to configure environment variables, small white users are easy to make mistakes.
2. Properly set the JDK installation path at Intellij IDEA
Click the File option in the upper-left menu bar of Intellij IDEA, and then click the Project Structure sub-option.

In the configuration page for Project Structure, the project-JDK must not be red as shown in the figure below, because red indicates that there is no corresponding JDK under the file path.

First, make sure that you have followed the first step above to find the current Java version on your computer through the black box command Java — Version. Otherwise, you will have to reinstall the JDK before you see this step. Under the Project SDK TAB, we clicked on the small triangle arrow in the drop-down box to see if Intellij IDEA had helped us find an alternative JDK version. If so, we checked that Intellij IDEA was basically back to normal by selecting the existing JDK in the drop-down box.

If there is no existing JDK version in the drop-down box, we need to manually click New… , then select the “install the latest JDK on our computer properly” installation path. If you’ve just reinstalled the JDK you must remember the JDK installation path. If you’ve forgotten where you installed the JDK, type Java –verbose — in the black box and the JDK installation path appears at the end of the command line.
3. Save the configuration of Project Structure and recompile it to run the Java program normally
After OK, compile Run again to Run the Java program as normal.

Read More: