Java Basic Learning Summary--java environment variable configuration

Source: Internet
Author: User
Tags tomcat server

Preface

  The first step of learning Java is to build the Java learning Environment, first of all to install jdk,jdk installed, but also need to configure the computer "Java_home", "path", "Classpath" the three environment variables to be able to build the Java development environment. In an environment where JDK is not installed, the PATH environment variable is a system variable that exists, and java_home and classpath do not exist.

First, configure the Java_home variable

Operation Steps (Win7 system): Computer → right Button "Properties" → advanced system settings → advanced → environment variables as shown:

Click " New " Under the system variable, pop up a new system Variable dialog box, first in the variable name write Java_home, as the name implies, the meaning of Java_home is the JDK installation path, and then in the variable value to write the JDK installation path, If the variable value set here is "D:\Program Files (x86) \java\jdk1.7.0", after setting the value of the variable, click the "OK" button, the JAVA_HOME environment variable is set to complete, as shown in: System variable more than one " Java_home "Variable

Second, the configuration PATH environment variable

Operation Steps (Win7 system): Computer → right Button "Properties" → advanced system settings → advanced → environment variables


Find the path variable in the system variable, click the "Edit" button, Pop-up dialog box to edit the system variables, you can see that the path variable is set up a lot of directories, each directory used between, (semicolon) separated, will%java_home%\bin; add to the variable value of the path variable, click " OK button, the PATH environment variable is set to complete as shown in:

Three Configuring CLASSPATH variables

The purpose of setting up the classpath is to tell the Java execution Environment, in which directory you can find the Java program (. class file) you want to execute, about this classpath variable, in fact, can not be configured, often see classpath= on the Internet. %java_home%\lib\dt.jar;%java_home%\lib\toos.jar, but learning Java so long discovered that not configuring CLASSPATH does not affect the development and operation of Java projects.

iv.Description of java_home variable,path variable,classpath variable 4.1. Purpose of setting the Java_home variable

First, for the convenience of reference, for example, the JDK installed in the D:\Program Files (x86) \java\jdk1.7.0 directory, then set Java_home as the directory path, then to use this path later, just enter%java_ Home%, avoid entering a long path string for each reference;
Second, the principle of normalization, when the JDK path is forced to change, only need to change the value of the Java_home variable.
Third-party software will refer to the agreed java_home variable, typically the Tomcat server, if you do not configure the Java_home variable, then the Tomcat server does not run up

4.2. Path variable (key Note)

The operating system uses path paths to find executables (. exe programs), and in Windows, when we tap any command, it is actually executing an executable file, such as entering the Notepad command to open a notepad

  

Actually executes the c:\Windows under the Notepad.exe this executable file, and with the mouse double-click Notepad.exe after the ability to open a notepad effect is the same

  

When you hit a command in the command window, the system will automatically look for the executable (. exe) file of the command, and if it does not exist, you will not be able to execute the command. The root directory of this executable file must be set in the PATH environment variable.

4.3. Display the environment variable set by path in the command window

Simply enter the "Echo%path%" command to display all the root directories of the PATH environment variable you set, as long as the corresponding. exe file exists in the root directory and the corresponding. exe file is executed when the command is typed.

  

Because the Windows directory where the Notepad.exe is located has been added to the PATH environment variable, this explains why the input command notepad can open a notepad, so when you configure the JAVA development environment earlier, you will%java_home%\ The purpose of the bin added to the path variable is to use the Javac and Java commands under the command-line window to execute both Javac.exe and Java.exe executable programs.

4.4.Classpath Variable Description

When compiling a. java file using the Javac command, if additional classes are required, they are also found through classpath.

When you execute a. class file using Java commands, the. class file that is executed is searched through Classpath.

Classpath represents the path to the class you are looking for.

V. Differences between user variables and system variables

As you can see from the above diagram, there are two variables in the environment variable, one is the user variable and the other is the system variable, so what is the difference between the two variables? User variables, as the name implies, are for a particular user, only valid for a particular user, and system variables are valid for any user. The following is a detailed description of the differences between user variables and system variables, in the context of configuring MAVEN's development environment.

Adding Maven_home User Variables

Click on the "new" button of the user variable, pop up the new User Variable dialog box, enter the variable name and the variable value to be created, click the "OK" button, and the new user variable will create, as shown in:

Add path User variable

Here are 2 new user variables added to the user variables of the currently logged-on system's GACL User: The maven_home user variable and the path user variable, the maven_home variable and the path variable are valid only for GACL users, and logging in with another user is not valid.

Now you can see that there are 2 path variables in the environment variables, one is the user variable path, the other is the system variable path,

So when you need to use the value of the path variable, which path to use, how to distinguish between the two path? When you need to use the PATH environment variable, the system practice is to use the value of the path user variable created by the user and the value of the path system variable together, or it can be understood that the operating system will add the value of the path user variable to the path system variable, Then use the path of the system variable.

Before adding a user variable to path, the value of the path variable is the value set in the system variable path, as shown in:

After adding the user variable path, the value of the PATH variable = the value set in the system variable path and the value set in the user variable path, as shown in:

Environment variables are not case-sensitive under windows, so the path variable name is not case-sensitive.

Http://www.cnblogs.com/xdp-gacl/p/3628220.html

Java Basic Learning Summary--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.