Table of contents
The simplest Java environment installation guide under Windows
【1 Introduction
-
JDK: Java SE Development Kit Java development tools
-
JRE: Java Runtime Environment Java Runtime Environment
If you want to engage in Java programming, you need to install JDK. If you just run a Java program, JRE will meet the requirements.
Java installation packages are divided into two categories. One is JRE, which is an independent Java running environment; the other is JDK, which is a Java development environment. However, the JDK release package contains an independent JRE. In addition, you need to pay attention to JDK itself has JRE built-in.
【2】Installation
When installing JDK under Windows, you must consider the number of bits of the installation package. If it is a 32-bit operating system, prepare it . If it is a 64-bit operating system, prepare it . The JDK installed below is for a 64-bit operating system. The installation method for a 32-bit operating system is the same.jdk-xxx-windows-i586.exe
jdk-xxx-windows-x64.exe
- Step 0: Preparation for installation package (JDK8 is installed in this article)
The following installation is also a 1.8 installation, except that the minor version number is different, and all other operations are the same.
-
Step 1: Execute the installation package
jdk-8u131-windows-x64.exe
. The following interface will appear. Click Next.
-
Step 2: Install the development tools and source code; the JDK installation package contains an independent JRE, which does not need to be installed as a development machine, so this function will not be used if selected here (Figure 2 below); it is not recommended to change the installation directory. Just use the default; click Next.
-
Step 3: Wait a moment for the installation to be completed.
【3】Configuration
Regarding the configuration of JDK, there are many methods circulated on the Internet, some of which are very complicated and completely undesirable. Before configuring, first figure out what to configure.
First:JAVA_HOME
environment variable, the value is the installation directory of JDK. Why is it configured like this? It is mainly because many open source software depend on this variable, which is used to find the Java environment on the machine, such as:,Tomcat
Maven
。
Second: AppendPath
the path of the Java command to the variable value. The reason is very simple. You want to be able to directly use the commands provided in the JDK on the command line, such as:,.java
javac
Third: Configure CLASSPATH.
Note: In JDK1.6 and later, to install the Java development environment, you only need to configure the first and second contents above.
-
Step 1: Configuration
JAVA_HOME
-
Step 2: Configuration
Path
. It should be notedPath
that the path generally exists and only needs to be appended. The meaning used here%JAVA_HOME%
is to directly referenceJAVA_HOME
the value configured above. The advantage of this is that if the Java installation directory changes,JAVA_HOME
the value that needs to be modified does not need to modifyPath
the value of the variable.important! ! In some Windows 10 systems, the configuration fails after restarting
%JAVA_HOME%\bin
. The solution here is to configure the full path, such as:C:\Program Files\Java\jdk1.8.0_131\bin
Note: The Path variable configuration of Windows 8 and 10 is more friendly. Just configure a record directly. If it is Windows 7, you need to use (English semicolon) to separate the value of the Path variable, and then append the bin;
in the Java installation directory. Directory path is sufficient.
-
Step 3: Configure CLASSPATH
Variable name: CLASSPATH Variable value: Pay attention to the preceding . This period cannot be omitted.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
【4】Inspection
After installing the JDK and the corresponding configuration, you need to verify whether the installation is successful and whether the configuration is normal.
-
Step one: Open
cmd
the command line window.
-
Step 2: Output
java -version
the command. If the output is as shown below, it means the installation and configuration are successful. Otherwise, you need to check whether the installation and configuration are correct.