Everyone who writes Java programs can configure JDK correctly, but since you don’t need to configure it again after the first configuration, you may forget it because of a long time when you need to reconfigure it. It also leaves a mark when written here for future reference.
Since you want to configure it, you must first download it. It is recommended to download it on the official website. According to needs, such as different operating systems, or 32-bit or 64-bit, in short, you must download the correct version. For example, I have a Win7 64-bit operating system, and the latest jdk-7u25-windows-x64 version is downloaded.
After the download is completed, double-click to install it. There is no need to introduce this. It can be installed by default or customized. The key is to know the installation path. For example: D:/Tools/jdk/Java/jdk1.7.0_25
Next, configure the environment variables: Right-click "My Computer" --> "Advanced" --> "Environment Variables"
1) Create a new JAVA_HOME variable in the system variable, the variable value is: D:/Tools/jdk/Java/jdk1.7.0_25 (fill in according to your own installation path)
2) Create a new classpath variable, the variable value is: .;%JAVA_HOME%/lib;%JAVA_HOME%/lib/tools.jar
3) Add variable value to the path variable (it already exists and does not need to be created): %JAVA_HOME%/bin; %JAVA_HOME%/jre/bin (note that the variable values are separated by ";")
After the configuration is completed, the following tests can be performed:
"Start" --> "Run" --> Enter "java" --> "Enter". If you can print normally, the usage will indicate that the configuration is successful!
Analysis of supplementary environment variables:
JAVA_HOME: jdk installation path
classpath: java loads the classpath. Only the java command can recognize the class in the classpath. A "." is added before the path to indicate the current path.
path: The system can recognize java and javac commands under any path.
The above is the detailed content of configuring JDK environment variables. I hope this article will be helpful to everyone's learning.