From the sophomore began to touch Java, followed by intermittent learning. Junior really started the Java journey, estimated that most beginners learning Java by the Java environment variables, although found the correct way to set the environment variables, but the reason smattering, the settings do not know why.
So far the setting of environment variables is not very understanding, and most of the information on the Internet is almost a setup method, did not say why. Learning Linux Today, encountered the settings of the Java environment variable, inadvertently found a detailed explanation of the Java environment variable settings.
“
1. Path environment variable. The function is to specify the command search path, and when executing the command under the shell, it looks in the path specified by the path variable to see if the appropriate command program can be found. We need to add the bin directory in the JDK installation directory to the existing path variable, and the bin directory contains the frequently used executables such as Javac/java/javadoc wait, and after setting the path variable, you can execute the Javac/java tool in any directory.
2. CLASSPATH environment variables. The role is to specify the class search path, to use the already written classes, the premise is to be able to find them, the JVM is through the classpth to find the class. We need to set the Dt.jar and Tools.jar in the Lib subdirectory of the JDK installation directory to classpath, of course, the current directory "." must also be added to the variable.
3. Java_home environment variables. It points to the JDK's installation directory, and software such as Eclipse/netbeans/tomcat finds and uses the installed JDK by searching for java_home variables.
”
Thank you for "SAMCN" here, thank you for this article, not only solves the problem in Linux, but also solves the confusion of learning Java for a long time. Thank you!
Why set the Java environment variable (detailed)