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
Second, configure environment variables
1》JAVA_HOME, value I:\JAVA\JDK (PS: This is the address I switched myself)
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
3》We configure Path to join the address, %JAVA_HOME%\bin, %JAVA_HOME%\jre\bin, %CLASSPATH%
%JAVA_HOME%\bin
%JAVA_HOME%\jre\bin
%CLASSPATH%
4 "At this time, we can enter the cmd command to check whether the installation is successful
java -version
javac
5 " In some cases, the javac command is invalid as follows. At this time, we only need to restart the computer.
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
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
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;”)**
4 "It has been changed, we reopen a new command window, and output again, obviously, this time there is no problem
5 "At this time, the output of the javac command is successful