Understanding a Java environment variable configuration

Source: Internet
Author: User

First, understand what an environment variable is: it refers to some parameters that are used in the operating system to specify the operating system's environment, which is an object with a specific name in the operating system and contains the information that the application will use, which is simple enough to understand To run the program, you need to look for the path from the environment variable to make the program run correctly

in JAVA, we need to configure three environment variables : Java_home, PATH, CLASSPATH, respectively.

The installation directory for Java_home:java, whose value is the directory where the JDK is installed. I understand that it is java_home this variable to facilitate the following PATH and Class_path to write it convenient hehe hey.

Path: is a command-line path.   For example, other command-line maven, Gradle,mysql command, because the Java command-line tool is stored in the jdk's Bin directory . windows under We generally write the path =%java_home%/bin

CLASSPATH: When the CLASSPATH environment variable is not configured, the a.class file is searched by default in the current directory, and only the A.class file is executed in the current directory. If you have a classpath variable, you can execute the a.class file in any directory.

But why some of the configuration environment variables in the tutorial will be configured classpath=.; Where's%java_home%\lib;%java_home%\lib\tools.jar?

In fact, after JDK1.5, there is no need to configure CLASSPATH. The original JDK itself cannot find the Tools.jar in the Jdk/lib directory, so this environment variable needs to be configured.

where "." In the current directory looking for the class to be compiled to configure the CLASSPATH variable, in order to make the Java interpreter know where to find the standard class library, these standard class libraries are already written by others, we just use. For example, we often use the class in the Java.lang package, after configuring the CLASSPATH variable is set as the default import, so you do not have to import this package when writing the program (your Java project does not import java.lang.String, etc.). So where are these standard libraries? In the file with the jar suffix in the Lib directory of the JDK: one is Dt.jar, the other is Tools.jar, and the two jar packages are located in the Jdk/lib directory.








          

  

Understanding a Java environment variable configuration

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.