The operating environment of this tutorial: Windows 7 system, Java 10 version, DELL G3 computer.
1. JAVA_HOME. Refers to the java installation directory. This is a rule. Whether it is oracle, tomcat or other software that needs to use jdk or jrm, you can find this environment variable directly in the operating system. Software developed by JAVA, such as Eclipse/Tomcat, finds and uses the installed JDK by searching the JAVA_HOME variable. If you do not configure the JAVA_HOME variable, you will find that Tomcat cannot start normally.
2. PATH environment variable. The function is to specify the java command search path. We need to add the bin directory under the jdk installation directory to the existing PATH variable. The bin directory contains frequently used executable files, such as javac, javaw, etc. After setting the PATH variable, you can execute tools such as javac/java in any directory. If you don't use these tools, you can only enter first.
3. CLASPATH environment variable. He tells the Java execution environment in which directories you can find the categories or packages required for the Java program you want to execute. Generally speaking, its functions are related to the import and package keywords. The java source code we write certainly contains tool categories provided by others. For example, if you write importjava.util.*, when the compiler faces the import keyword, it needs to know where the categories you introduced into java.util are. Same as above, if you don’t tell it, it will default to the current directory. How to tell it? Just set CLASPATH.
After installing the java version, we will then configure the java environment. For newbies, some of these variables need to be entered manually.
The above is the role of java environment variables. From this we can know that the directories, paths, and execution environment in java all need to rely on environment variables to operate. After everyone learns, you should quickly configure the environment variables on your computer.
More Java learning guide: java tutorial