To configure JDK environment variables, follow these steps:
1. My computer --> properties --> advanced --> environment variables.
2. Configure user variables:
A. Create JAVA_HOME
C: \ Program Files \ Java \ j2sdk1.5.0 (JDK installation path)
B. Create a PATH
% JAVA_HOME % \ bin; % JAVA_HOME % \ jre \ bin
C. Create a CLASSPATH
.; % JAVA_HOME % \ lib \ tools. jar
3. test whether the environment variable configuration is successful:
Start --> Run --> CMD
Press on the keyboard: JAVAC JAVA
The corresponding command appears, rather than the error message, indicating that the configuration is successful!
Environment Variable Configuration:
1. PATH environment variable. The function is to specify the command search path. Execute the command below the I command line, for example, when javac compiles a java program, it will go to the PATH specified by the PATH variable to check whether the corresponding command program can be found. 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/java/javadoc waiting, after setting the PATH variable, You can execute tools such as javac and java in any directory.
2. CLASSPATH environment variable. The function is to specify the Class search path and use the classes that have already been compiled. The premise is that you can find them, and JVM searches for classes through CLASSPTH. We need to set dt. jar and tools. jar in the lib subdirectory under the jdk installation directory to CLASSPATH. Of course, the current directory "." must also be added to this variable.
3. JAVA_HOME environment variable. It points to the jdk installation directory. Eclipse, NetBeans, Tomcat, and other software find and use the installed jdk by searching the JAVA_HOME variable.