Before the environment variable is configured, executing the Java file with CMD requires that the Java executable be indicated, otherwise it will not run.
The environment is configured to facilitate the execution and control of Java programs without having to switch the executable directory.
The environment variable is to let the system directly find the executable file according to the parameters of the environment variable.
The difference between a system variable and a user variable
user variables are affected by the current user, and system variables have an impact on all users. affect other users in order to make some changes to yourself. So to set user variables, avoid affecting his users.
If all two are set, the configuration of the system variable is preferred.
Steps to configure environment variables:
First step: My Computer right -- Property --- advanced system settings Step Two: System Variables - new --java_home- directory of the JDK you installed --c:\program files\java\jdk1.8.0_73 The third step: the system variable --- new --classpath, the value is:.; %java_home%\lib;%java_home%\lib\tools.jar Notice that there is a point ahead. Fourth Step: Select the system variable ---path-- edit -- Add the following code at the end of the Path :%java_home%\bin;%java_home%\jre\bin, Note Be sure to split the semicolon before adding it. Java-version detect if the installation is good!
Why Java configures environment variables and how to configure environment variables