JCreator Error : Invalid path...

created at 12-06-2021 views: 21

error

jcreator  Error : Invalid path...D:\Program Files (x86)\Java\...JDK...

Failed to establish a connection with the target VM...

jcreator hasn't been used for a long time, a simple Java program can't run, the error keyword is as above.

The rough meaning is that the path of the JDK is wrong.

I followed the suggested path to check and found that Java is empty and the original JDK has been deleted.

solution

The solution steps are as follows

  1. Find JDK Profiles in jcreator configuration;
  2. Delete the original JDK version, regardless of the red or black
  3. Add the currently installed JDK into it (after clicking `new`, find your own JDK installation directory)

Explain: jcreator and JDK are two different things. The purpose of the operation is to make jcreator correct the JDK we installed. It must refer to the location of the JDK.

JDK profiles

general principle:

For example, to write a Hello.java program, we need to use JDK to compile and run it.

JDK (mainly provide compilation tool javac.exe, compile the source program Hello.java into bytecode file Hello.class)

JRE of JDK (interpret Hello.class into machine instructions through java.exe, give it to the machine to execute, and output Hello !)

Therefore, if a program wants to be read by a machine, it cannot do without javac.exe and java.exe, both of which are in the bin directory of the JDK installation directory. After downloading and installing JDK from www.oracle.com, we need to configure two (system) environment variables,

One is to create a new JAVA_HOME, fill in the JDK installation directory

The second is to edit the original PATH and add %JAVA_HOME%\bin

After setting up these two environment variables, press the keyboard win+R and enter cmd in the windows system, and the DOS window will open. Enter the command javac and press the Enter key. If many lines of version information pop up, it means that the JDK configuration is successful.

Follow the steps in the screenshot and add the successfully configured JDK to JCreator, and then you can edit and run Java programs in it.

Finally, explain why it is the **JRE** of JDK

The JDK can compile programs, and the JRE can only run the compiled product of the JDK: bytecode files. When the JDK is installed, its own JRE is installed. The program developer writes the `.java` source program, which must use the JDK; while ordinary users get the compiled bytecode file, instead of having to install the JDK, just install a separate JRE, the program will still run and output Hello !.

created at:12-06-2021
edited at: 12-06-2021: