Java Development Platform JDK environment variable configuration under Windows

Source: Internet
Author: User

Http://blog.sina.com.cn/s/blog_76e84df301015edc.html

After the JDK installation is complete, you typically need to set the values for Java_home, CLASSPATH, path three environment variables, and test the JDK configuration for success.

First, what is a user variable? What is a system variable?

A: User variables are variables that can only be used by the current user, and system variables are variables that are available to any user under the system.

Second, why do I need to configure environment variables?

A: We know that in the "Run" window of the system can enter the specified command to run the corresponding program, if the command is entered without specifying the full path, the system will automatically find the corresponding file in the current directory, if not found, and then to the system environment variable path to find, but, Because Java adheres to some of the UNIX specifications, it does not look for files in the current directory, so it must be set in an environment variable.

Thirdly, what is the function of the system environment variable Java_home?

A: Java_home represents the directory where the JDK is installed, and if other applications need to use the JAVA runtime environment, they will first get the value of the variable and then determine the path of execution based on that value.

1, convenient reference, for example: JDK installed in the C:\Program files\java\jdk1.7.0_04 directory, then set java_home value for the directory path, the future use of this path, only need to input%java_home% to Avoid entering the "C:\Program files\java\jdk1.7.0_04" path for each reference.
2, the principle, when the JDK path changes, only need to change the value of the java_home variable, otherwise, you need to change the value of all variables using this path.

Set Variable name: Java_home

Set the variable value: C:\Program files\java\jdk1.7.0_04 (this variable value is not a deterministic value, to be configured according to the installed path and installed version, there is the value of this variable is a value, so there is no need to separate the "semicolon", "semicolon" Separated by two variable values)

Iv. what is the function of the system environment variable classpath?

A: The CLASSPATH environment variable represents the path to the search Java class, which specifies the location of the class library, and the JRE folder under the JDK installation directory contains the Java class files required to run the Java application, which are placed in the compressed package Rt.jar in the Jre\lib directory. Classpath variables in the ".; "refers to a class file that can load the application's current directory and its subdirectories, where". "Represents the current path, because each variable is separated by semicolons, so this" dot semicolon "is also an environment variable value, so it should be easier to understand and accept it.

Set Variable name: CLASSPATH

Set the value of the variable:.; %java_home%\lib\dt.jar;%java_home%\lib\tools.jar;%java_home%\jre\lib\rt.jar;

Note: The beginning of the "dot semicolon" in the first and the end can be, put in the middle should be careful to write between the variable value and the variable value, do not write in the value of the variable.

For example:%java_home%\lib\dt.jar;.; %java_home%\lib\tools.jar;%java_home%\jre\lib\rt.jar

The effect of these three packages on Dt.jar,tools.jar and Rt.jar is not explained here.

Five, why some textbooks are about the need to configure the environment variable Classpath value, and some textbooks are not configured Classpath value?

A: Installing the JDK generally does not require setting the value of the environment variable classpath, but sometimes other applications installed by the computer may modify the value of the environment variable classpath, then when running the Java program, it is likely to load these software products with the old version of the class library, This causes the program to load the class cannot be found, so that the program does not work properly, you need to reconfigure the environment variable classpath value.

Vi. What is the role of the system environment variable path?

A: The path variable is the way the system searches for executable programs, and we want to execute the Java compiler (Javac.exe) and Java provided in the JDK platform without writing out the full path of the JDK Interpreter (Java.exe), you need to specify the full installation path of the JDK in the system's environment variable path value, so after installing the JDK, you must configure the value of the environment variable path. The Java compiler (Javac.exe) and the Java Interpreter (Java.exe) are in the bin file in the Java installation directory.

Set Variable name: PATH

Set Variable value:%java_home%\bin;

Note: When setting the environment variable path value, if the path variable does not exist in the system environment variable, create a new path variable, and if there is a path variable, do not replace the value of the original path variable, because in the value of the original path, May include the path value for other programs that are automatically configured in the system, and may cause other programs to not function properly if they are replaced.

Java Development Platform JDK environment variable configuration under Windows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.