The process of JDK installation and configuration of environment variables under WIN10 (detailed version)

The process of JDK installation and configuration of environment variables under WIN10 (detailed version)

If you want to learn JAVA, you must install JDK (Java Development Kit) and configure the environment variables before you can learn Java. After several failed attempts to configure the environment variables, I finally succeeded. This blog post is formed by summarizing the problems encountered. Welcome to communicate. [Of course, I’m a newbie.] 】Common reasons for failure are as follows:

  • Installation problem: Installing jdk and jre in the same folder causes the "original files in jdk" to be overwritten. (A javac instruction error occurred.)
  • Variable confusion: After opening the environment variable setting box, there are two categories: "user variables" and "system variables". We need to configure system variables.
  • Path error: The variable value of JAVA_HOME variable is the file path of the "jdk" we installed. (Direct copy and paste is recommended.)
  • Statement error: The variable value of CLASSPATH is wrong, there must be a dot "." at the beginning! ! ! (Direct copy and paste, see below.)
  • Path error: The variable value in Path under win10 only recognizes the absolute path and cannot be referenced as %java_home%.

1. Download JDK (take jdk1.8.0 as an example)

You can download it directly from CSDN. I have personally tested the following resources and found them to be effective.
JDK1.8.0 Download

Once the download is complete, it should look like this.

After the download is complete, it will be an installation program.

2. Install JDK (do not use next without thinking)

When the installation program is in progress, first install the jdk (default path: C:\Program Files(x86)\Java\jdk1.8.0-60\) and then install the jre (default path: C:\Program Files(x86)\Java\jre1.8.0-60\). We don’t like to install so many software on the C drive. When we customize the installation, if they are all installed in one folder, the later installed jre will overwrite the original files. That is to say, jre must be installed in another folder.

Check method: Open the directory where JDK is installed, search for javac.exe in the bin folder, if it is not there, it has been overwritten. When I check the installation at the end, both java -version and java commands can be executed, but javac command will show: javac shows "not an internal or external command.
Click the installer to run it directly. [Go directly to the picture]

JDK installation
Custom
jre installation

My suggestion is: before installation, create a java folder in the target disk, and create two folders, jdk and jre, under this folder, and install them respectively.

insert image description here

At this point, JDK has been installed correctly.

3. Configure JDK environment variables

Right-click This PC, click Properties, and then click Advanced system settings.

insert image description here

Create a new system variable JAVA_HOME (write directly)

insert image description here

Create a new system variable CLASSPATH (write directly)

insert image description here

Variable value: (Don't lose the first one!!!) (Strictly copy)

.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;

Adding a dot means that you can run Java in any directory.

Edit the system variable Path (add two values)

insert image description here

Many installation tutorials write %java_home% here, but the Path under the win10 system does not support %java_home%, which represents the value of the java_home environment variable and is a reference. But the absolute path must be used here in win10.

At this point, you have completed the configuration of environment variables. Normally, you have succeeded. Let's check it below.

4. Check whether the environment variables are correct

Press WIN+R, enter cmd, enter the command line interface, and perform three checks.

java -version check

enter:

java -version

insert image description here

2. Java inspection

java

insert image description here

3. Javac check

javac

At this point, you have completed the JDK installation!

insert image description here

If other errors are found, you can check whether the Chinese and English formats, uppercase and lowercase letters, and paths are correct.

V. Other Notes

1. User variables and system variables

There are two locations for setting environment variables, one is user variables and the other is system variables. User variables are only useful to the user, and system variables are useful to the system. If there are two users on your computer, setting it in user variables is only useful for the current user, while setting it in system variables is useful for both users. Generally, it is set in the system variable location.

2.java and javac

javac: is a compilation command that compiles Java source files into .class bytecode files.
For example: javac hello.java will generate hello.class file.
Java: It runs bytecode files; the bytecode is interpreted and run by the Java virtual machine. For example: java hello
For details, please see: Use and precautions of javac and java in cmd

Summarize

This is the end of this article about the process of JDK installation and configuration of environment variables under WIN10 (detailed version). For more relevant content about configuring JDK environment variables under WIN10, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Win10 Java jdk14.0.2 installation and environment variable configuration detailed tutorial
  • win10 java (jdk installation) environment variable configuration and related issues
  • JDK13.0.1 installation and environment variable configuration tutorial with pictures and text (Win10 platform as an example)
  • Detailed tutorial on jdk installation and environment variable configuration under Win10

<<:  Solution to leaving gaps between BootStrap grids

>>:  Use Grafana+Prometheus to monitor MySQL service performance

Recommend

18 sets of exquisite Apple-style free icon materials to share

Apple Mug Icons and Extras HD StorageBox – add on...

Solution to Ubuntu 20.04 Firefox cannot play videos (missing flash plug-in)

1. Flash plug-in package download address: https:...

Summary of commonly used tags in HTML (must read)

Content Detail Tags: <h1>~<h6>Title T...

Detailed explanation of padding and abbreviations within the CSS box model

As shown above, padding values ​​are composite at...

Tips for viewing History records and adding timestamps in Linux

Tips for viewing History records and adding times...

A detailed introduction to wget command in Linux

Table of contents First install wget View Help Ma...

Two ways to clear float in HTML

1. Clear floating method 1 Set the height of the ...

Docker configures the storage location of local images and containers

Use the find command to find files larger than a ...

Linux virtual memory settings tutorial and practice

What is Virtual Memory? First, I will directly qu...

How to implement mask layer in HTML How to use mask layer in HTML

Using mask layers in web pages can prevent repeat...

How to build a redis cluster using docker

Table of contents 1. Create a redis docker base i...

Detailed explanation of the lock structure in MySQL

Mysql supports 3 types of lock structures Table-l...

Detailed tutorial on installing MySQL 8.0.20 database on CentOS 7

Related reading: MySQL8.0.20 installation tutoria...

CSS sets the box container (div) height to always be 100%

Preface Sometimes you need to keep the height of ...