Installing the JDK environment in Java – the javac command is invalid

Installing the JDK environment in Java – the javac command is invalid

One, install JDK1.8

Alibaba cloud disk address recommendation

We can choose the installation address . This address is used to configure environment variables. The only thing to pay attention to is this, and the others are the default next step. Until the installation is complete, jdk download address https://www.oracle.com/java/technologies/javase-downloads.html

img

Second, configure environment variables

1》JAVA_HOME, value I:\JAVA\JDK (PS: This is the address I switched myself)

img

2》CLASSPATH, value**.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar (PS: there is a dot in the first place here)**

.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar

img

3》We configure Path to join the address, %JAVA_HOME%\bin, %JAVA_HOME%\jre\bin, %CLASSPATH%

%JAVA_HOME%\bin 
%JAVA_HOME%\jre\bin
%CLASSPATH%

img

4 "At this time, we can enter the cmd command to check whether the installation is successful

java -version

img

javac

img

5 " In some cases, the javac command is invalid as follows. At this time, we only need to restart the computer.

img

Three, javac exception

1》We first confirm whether javac can run, and execute javac in the directory of the file, and find that it is possible, which proves that our installation is correct, it is the problem of environment variables, as shown in the figure below

img

2》We output pah to check whether the environment variable address is configured correctly. After checking the address, the following two symbols are added. Let’s check the path

img

3》Check and find the problem, win10 can’t add a semicolon after it, we remove it, adding a semicolon will cause an address error, the error display is as shown in the picture above**(;“I:\JAVA\JDK\jre\bin;”)**

img

4 "It has been changed, we reopen a new command window, and output again, obviously, this time there is no problem

img

5 "At this time, the output of the javac command is successful

img

Guess you like

Origin blog.csdn.net/weixin_45285213/article/details/129182814