- Download JDK
- Link: https://www.oracle.com/java/technologies/downloads/.
(https://www.oracle.com/technetwork/java/javase/overview/index.html)
Choose a suitable version of JDK for yourself and download it. The specific installation steps are as follows:
- Briefly explain what JDK is:
SUN Corporation provides a Java development environment, abbreviated as JDK (Java Development Kit), which is the core of Java, including Java compiler, Java runtime tools, Java document generation tools, Java packaging tools, etc.
In addition to providing JDK, SUN Corporation also provides a tool called JRE (Java Runtime Environment), which is a Java runtime environment provided for ordinary users. Since users only need to run pre-written programs without writing programs themselves, the JRE tool only contains Java runtime tools and does not include Java compilation tools. It is worth mentioning that for convenience, SUN Corporation includes a JRE tool in its JDK tool, which means that the development environment includes the runtime environment. Therefore, developers only need to install JDK on their computers and do not need to install the JRE tool separately.
- JDK version introduction:
SE (JavaSE), standard edition, is a version that we usually use. Starting from JDK 5.0, it was renamed Java SE.
EE (JavaEE), enterprise edition, is used to develop J2EE applications using this JDK. Starting from JDK 5.0, it was renamed Java EE. Starting from February 26, 2018, J2EE was renamed Jakarta EE [1-2].
- Environment configuration
2.1. My Computer -> Right-click Properties -> Advanced System Settings -> Environment Variables
2.2. System Variables -> New System Variable -> Click OK after completion
Variable Name: JAVA_HOME
Variable Value: (This is the path where you installed JDK)
Purpose: Define a variable for use elsewhere
2.3. Double-click the PATH variable under System Variables and add two paths
Purpose: Allow the system to recognize java, javac, javap, and other commands in any path
%JAVA_HOME%\bin
%JAVA_HOME%\jdk\bin
2.4. Create/modify the CLASSPATH variable
(1) If the CLASSPATH variable exists, select it and click Edit
(2) If not, click New... to create it
(3) Enter: (Purpose: Tell the JVM where to find the class to be used or executed, .; represents the current path, tools.jar and dt.jar are library paths)
Variable Name: CLASSPATH
Variable Value: .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
2.5. Test if JDK is installed successfully
After all the configurations are completed, test JDK by pressing win+R, enter cmd to open the command window
Enter: java -version