Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Configuration and basic principle of JDK Environment variable in JAVA of Yangge University Lecture Hall

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Many students often ask questions about the configuration of JDK environment variables. now sort out the steps and basic principles of configuration so that you can thoroughly understand and learn to configure independently.

1. Basic configuration:

1. For example, if we have installed the version of jdk1.8, when we install JDK and select the installation directory, two installation prompts will appear during the installation process. The first time is to install jdk, the second time is to install jre, it is recommended that both are installed in different folders in the same java folder.

2. To configure the environment variable, right-click the computer → to select Properties →, click Advanced system Settings →, select Advanced →, click the environment variable, and enter the interface shown below:

3. Create a new JAVA_HOME variable in the system variable, enter the jdk installation directory for the variable value, and then click OK, as shown in the following figure:

4. Find the Path variable in the system variable, click the edit button, and enter% JAVA_HOME%\ bin;%JAVA_HOME%\ jre\ bin; at the end of the variable value. if there is no; sign at the end of the original Path variable value, enter the; sign first and then enter the above code. As shown in the following figure:

5. Create a new CLASSPATH variable in the system variable and fill in the variable value.;% JAVA_HOME%\ lib;%JAVA_HOME%\ lib\ tools.jar

Note: there is a little bit in the front! As shown in the following figure:

6. After the system variable is configured, check whether the configuration is successful. To do this, run cmd and type java-version, as shown in the following figure. Displays the version information of jdk1.8.0_31, indicating that the installation and configuration were successful.

Second, the configuration principle:

An environment variable is a variable, which can be simply understood as a "global variable" in a computer. Let's explain in detail the understanding of each environment variable.

1, JAVA_HOME environment variable: it points to the jdk installation directory, because everyone's installation directory may be different, other applications need to specify a JAVA_HOME environment variable, need to use JDK procedures, as long as reference JAVA_HOME on it. Commonly used software such as Eclipse and Tomcat search for JAVA_HOME variables to find and use JDK.

2. PATH environment variable: after writing a Java program, shell (command interpreter) will look in the path specified by the PATH variable to see if the corresponding command program can be found. Javac and java are not available locally. They exist in the bin directory of the JDK you installed, and the bin directory contains frequently used executables such as javac/java/javadoc and so on. So we need to add the bin directory to the existing PATH variable.

3, CLASSPATH environment variable: the function is to specify the class search path, to use the written classes, of course, the premise is that they can be found, JVM is through the CLASSPTH to find classes. We need to set dt.jar and tools.jar in the lib subdirectory under the jdk installation directory to CLASSPATH and, of course, the current directory. " You must also add to this variable.

Not only JDK, many development tools have to configure environment variables after installation, such as Hadoop, the principle is similar. So when we configure environment variables, we need to know not only how to configure them, but also why (how to configure them). Only in this way can we integrate the knowledge and learn the essence.

More highlights are in the video course of Brother Yang. Address: http://edu.51cto.com/lecturer/5811414.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report