Integrated development environments (such as Eclipse) give developers so much convenience that even beginners don’t know how programs generate executables from source code. The same is true for environment variables, except that to develop Java on a new computer, the first step after installing the JDK is to configure environment variables. There may not be a definitive understanding of why configuration is required. With a confused mind that probably meant that.
The first is the environment variable. Quoting the definition of Baidu Baike:
An environment variable is an object with a specific name in the operating system that contains information that will be used by one or more applications. For example, the path environment variable in Windows and DOS operating systems, when the system is asked to run a program without telling it the full path of the program, the system should not only look for the program in the current directory, but also look for the path specified in the path. Users can set environment variables to better run the process.
Windowing confuses this concept. It can be said that Windowing encapsulates commands, giving the operating system instructions just as the command line does. So when you run a javac command in a directory, it first looks for the javac executable file in the current directory, perhaps javac.jar or javac.exe. If the command cannot be found, look for it in the environment variable set by the operating system. If the command cannot be found again, it is said that there is no such command. That’s what environment variables do. It’s easy to understand what comes behind the concept of environment variables.
Next is JAVA_HOME. Java installation directory. This is a regulation, whether oracle, Tomcat or other software needs to use JDK, JRM, are directly to find the operating system environment variable. Maybe you’re the first to use this environment variable, like when you set path to “; %JAVA_HOME%\bin “instead of” C: Program Files (x86)\Java\bin “. %JAVA_HOME% is the JAVA_HOME environment variable.
The third is the PATH environment variable. The Java command search path is specified. We need to add the bin directory in the JDK installation directory to the existing PATH variable. The bin directory contains frequently used executable files such as javac, Java, javaw, etc. After setting the PATH variable, you can run javac/ Java and other tools in any directory. If you don’t, you’ll have to go to this directory before you can use those commands.
Finally, the CLASSPATH environment variable. It tells the Java execution environment where to find the classes or packages needed for the Java program you want to execute. Improt java.util.*, when you write improt java.util.*, the compiler looks at the import keyword. You need to know exactly where the classes are in the package you’re introducing java.util. As above, if you do not tell it, it defaults to the current directory, and how to tell it? Set the CLASSPATH.