When I first learned Java, I learned how to configure the environment variables. After many tossing times, I configured the environment variables. However, I did not care about the usage of each configuration item, once it can be used, it will be seldom taken care of. After a long time, we will understand the approximate functions of those variables.
1. java_home: Set it to the JDK installation directory, for example, D: \ Java \ jdk1.6. Some software dependent on Java obtains the JDK installation directory through this environment variable, such as Eclipse and tomcat.
2. Path: Add % java_home % \ bin at the end of the existing value, where; Is a separator used to separate each directory, % java_home % is the value of the above java_home environment variable, which can be directly replaced by the JDK installation directory. The classpath below is similar. The execution path (that is, the value of the PATH environment variable) is a list of directories that only search for local executable files in the operating system, it searches for the corresponding program in the execution path. Therefore, after adding the % java_home % \ bin directory to the path, you can execute javac or Java commands in shell.
3. classpath: set the value .; % java_home % \ Lib \ DT. jar; % java_home % \ Lib \ tools. jar; pay attention to the punctuation, the first vertex ". "indicates the current directory, while"; "indicates the separator.
This classpath loads the class directory for JVM, such as helloworld. there are other import classes in Java. During javac compilation, it will find the class you imported in classpath. If it cannot be found, a compilation error will occur.
In addition, when using Java, you can use the-classpath parameter to specify the directory of the class to be loaded. For example, run the command line: C:/usersjakey> JAVA-classpath D: \ Temp helloworld, in this way, you can execute the Java class in the d directory when the command line is in drive C.