Table of contents
This article uses Windows system and JDK1.8 version as an example. The steps for other versions are similar.
1. Introduction to JDK
JRE (Java Runtime Envirnment): Java runtime environment
Including JVM (Java Virtual Machine) and the core class libraries required by Java programs, so if you just want to run a Java program, you only need to install jre.
JDK (Java Development Kit): Java language software development tool kit
jdk includes java development tools and JRE, so as developers, we need to install jdk
2. Download JDK
Official website address: Java Downloads | Oracle
After entering the official website, scroll down, find JAVA8, and then click Windows
Then select the corresponding version (X64 represents a 32-bit system, X86 represents a 64-bit system)
Then follow the prompts to log in, and then the file will be downloaded automatically.
After the download is completed, you will get the following installation package
3. Install JDK
Click on the downloaded installation package to install it
Click next
At this time, click Change to customize the installation directory (remember the path, which will be used later when configuring the environment). It is recommended to create a separate folder for storage (you can also place it in this folder when installing JRE later). What I put here is the D drive.
Wait for the progress to complete, and then the installation of JRE appears.
You can also customize the installation directory by clicking Change here. I also put the D drive here, then click Next and wait for the progress to complete.
Just choose to close here.
4. Configure JDK
Enter the environment variables (two entry methods are introduced below)
1. Right-click My Computer => Properties => Advanced System Settings (win10 is on the right, win11 is probably in the middle) => Advanced => Environment Variables
2. Enter settings=》System=》About=》Advanced system settings (win10 is on the right, win11 is probably in the middle)=》Advanced=》Environment variables
Then select New under System Variables
Fill in the corresponding content below for the variable name and variable value.
Variable name JAVA_HOME
The variable value D:\jdk-1.8 is the installation address of your jdk just now.
Then click OK
Create a new classpath again, the steps are the same as above
variable name classpath
Variable value .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
Then click OK, and then find the path item in the system variable
Find it, select it, and then click Edit (you can also double-click Path directly)
Then create the following two items in sequence:
%JAVA_HOME%\bin
%JAVA_HOME%\jre\bin
Finally, press win+r on the keyboard and enter cmd, then enter
java -version
Obtaining the following results represents success