Java environment variable configuration, java environment variable

Source: Internet
Author: User

Java environment variable configuration, java environment variable

  This article draws on others'

The first step to learning java is to build a java learning environment. First, install JDK. After JDK is installed, you also need to configure the "JAVA_HOME", "path", and "classpath" environment variables on your computer to build the java development environment. In an environment where jdk is not installed, the path environment variable is a system variable that originally exists, while JAVA_HOME and classpath do not exist.

First, configure the JAVA_HOME variable and right-click my computer.→Attribute→Advanced System settings→Create a new variable named JAVA_HOME with the variable value as the jdk installation directory (for example:D: \ Java \ jdk1.7.0After the environment variable is created, a "JAVA_HOME" variable will be added to the system environment variable.

Configure the path variable. Find the path variable in the system environment variable (in Windows, the environment variable is case insensitive). Click the edit button to bring up the Edit System Environment dialog box, there are many directories in the path variable value. We can see that the directories are separated by semicolons, therefore, we add % JAVA_HOME % \ bin to it. Remember to separate them with semicolons and complete the path environment variable configuration.

Finally, we configure the classpath variable and set the Classpath to tell the Java execution environment where the Java program (. class file). You don't need to configure this ClassPath variable. You can see Classpath =. on the Internet .; % JAVA_HOME % \ lib \ dt. jar; % JAVA_HOME % \ lib \ toos. jar, but after learning java for so long, I found that neither configuring ClassPath nor affecting java project development and running.

Appendix: JAVA_HOME variables, Path variables, ClassPath variables, differences between system variables and user Variables

JAVA_HOME variable

1. For reference convenience, for example, JDK is installed onD: \ Java \ jdk1.7.0In the directory, set JAVA_HOME to the directory path. To use this path later, you only need to enter % JAVA_HOME % to avoid entering a long path string for each reference;
Ii. Normalization principle: When the JDK path is forced to be changed, you only need to change the variable value of JAVA_HOME.
3. Third-party software will reference the agreed JAVA_HOME variable, typically the tomcat server. If the JAVA_HOME variable is not configured, the tomcat server cannot run at all.

Path variable

The operating system uses the handler of pathto find the executable program (.exe Program). In windows, when we press any command, we actually execute an executable file. If we enter the notepad command, we can open a notepad, which actually runs c: \ The notepad.exeexecutable file under Windows is the same as opening a notepad with the mouse hitting notepad.exe.

The system will automatically find the executable file (.exe) corresponding to this order. If this file does not exist, it will certainly not be able to execute this command. The root directory of the executable file must be set in the path environment variable.

Enter"Echo % path %Hosts file. Because the Windows directory where notepad.exe is located has been added to the Path environment variable, this explains why you can open a notepad by entering the notepad command. Therefore, when configuring the java development environment, run the two executable programs % JAVA_HOME % \ Program.

Classpath variable

Use the javac command to compile. if other classes are required for java files, they are also found through classpath and executed using java commands. class file,. the class file is found through classpath. Classpath indicates the path of the class to be searched.

Differences between system variables and user Variables

There are two types of environment variables: User variables and system variables. What are the differences between the two variables? User variables, as the name implies, are for a specific user and only valid for a specific user, while system variables are valid for any user.

Sometimes we configure the Path variable in the user variable. Before adding the user variable Path, the value of the Path variable is the value set in the Path of the system variable. After adding the user variable Path, the value of the Path variable = the value set in the Path of the system variable + the value set in the Path of the user variable.

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.