Three environment variables need to be set in Java (1.5 no longer set CLASSPATH, but individuals are strongly advised to continue setting to ensure a downward-use problem)
After the JDK installation is complete, we will set the environment variables: right click on "My Computer", select "Properties", select "Advanced" tab, enter environment variable settings, set the following three environment variables respectively:
(1) Configure the PATH variable:
Why are you configuring the path variable?
Because the computer system will be based on the value of the variable to find some of the Java programming needs of the program, such as Javac.exe, Java.exe, Javah.exe and so on, Where the Javac.exe program is used to compile Java source code, the Java.exe program is used to perform the suffix to class code.
How do I configure the path variable?
Path variable general computer systems have been created, so instead of creating a new variable, simply select the path variable in the system variable and click "Select"-> "edit", and notice that you don't just delete the other path values in the box, but first add a semicolon after that big string of values, Then put the C:\Program files\java\jdk1.5.0_17\bin into the fields. The key value pairs are listed below:
Variable name: PATH (case-insensitive but recommended to use uppercase)
Variable Value: C:\Program files\java\jdk1.5.0_17\bin
(2) Configure the CLASSPATH variable:
Why do you want to configure the CLASSPATH variable?
Configuring the CLASSPATH variable allows the Java interpreter to know where to find the standard class libraries that others have already written, and we just use them. For example, we often use the class in the Java.lang package, after the configuration of the CLASSPATH variable is set as the default import, so you do not need to import this package when you write the program. So where are the standard libraries? In a file with a jar suffix in the JDK's lib directory: one is Dt.jar, the other is Tools.jar, all two jar packages are located in the C:/jdk1.6.0/lib directory. So we usually add these two jar packs to our CLASSPATH environment variable with the value:.; C:\Program Files\java\jdk1.5.0_17\\lib\tools.jar; C:\Program Files\java\jdk1.5.0_17\\lib\dt.jar;
How do I configure the CLASSPATH variable?
in the System environment variable, click New Classpath, the procedure is omitted, the following list only its key value pairs:
Variable name: CLASSPATH
Variable value:.; %java_home%\lib\tools.jar;%java_home%\lib\dt.jar;
(Note that the classpath is preceded by a "." That represents the current directory. Surround Java_home with two% this variable means to refer to the value of the variable, of course, if you do not want to do so, you can also configure the Classpath value is:.; %java_home%\lib\tools.jar;%java_home%\lib\dt.jar; That is, replacing%java_home% with the value of the java_home variable;
(3) Configure the Java_home variable:
Why do you want to configure CLASSPATH environment variables?
One is to facilitate the reference, for example, the JDK installed in the C:\Program files\java\jdk1.5.0_17 directory, then set the Java_home as the directory path, then use this path later, just enter the%java_home%, Avoid entering a long path string for each reference;
Two is the principle of normalization, when the JDK path changes, only need to change the value of java_home variable, otherwise, you must change any use of absolute path to refer to the JDK directory documents, if not, a program can not find the JDK, the consequences can be imagined----system crashes!
Third, the Third-party software will refer to the agreed java_home variables, otherwise, you can not use the software normally.
How do I configure the java_home variable?
in the System environment variable, click the new Java_home (Java_home is pointing to the JDK installation path), the value of the variable is actually the root directory of the JDK installation path. If the procedure is omitted, only its key value pairs are listed below:
Variable name: java_home
Variable Value: C:\Program files\java\jdk1.5.0_17
Test if the JDK is installed successfully
Enter CMD in run
then enter Java–version
See if you can display the Java version you have configured
The above is the Java environment variable configuration process, and why configure the PATH variable, classpath variable, and java_home variable reasons, I hope this article for everyone's learning help.