Configuration and detailed explanation of java environment variables

The author started to learn java courses this semester. To learn java development, you first need to configure java runtime environment variables. Although the teacher in class also talked about how to configure java environment variables, many of my classmates still don't know how to configure them, so I have recently configured java environment variables many times. The author explains in detail the assembly from JDK installation to environment variables as follows.


Table of contents

Download and install JDK

Configure java environment variables

JAVA_HOME variable

Path variable

ClassPath variable

Explanation of classpath variable configuration

Verification of the java runtime environment



First, Baidu directly searches for JDK, and then opens Oracle's jdk download page. (If you are lazy, here is the link)

https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Next, don't forget to choose to accept the agreement, and then open the system settings panel to check the system digits of the computer you are using. (64-bit or 32-bit)

If you choose the green clipper for 32-bit, the red arrow if you choose for 64-bit. (If it is an Apple computer, please choose the Mac option yourself)

After the download is complete, open the installation package and click Next until the steps in the figure below.

The author recommends that the operating environment similar to this language be installed on the C drive. If there is insufficient space on the C drive, or if you are more concerned, please click Change and select the path you want (it is recommended to put it in a newly created empty folder)

(Here is a stolen picture, because the author’s computer has already installed two sets of environments, so I didn’t install it again)

Note: Remember this path, it will be used in later steps.

Then continue to click Next until the steps in the figure below. (Pirate picture)

Here, if the path was changed in the previous step, select Change (note: it must be saved in the same directory as the previous one). If there is no change in the previous step, click Next.

Someone here may ask, didn’t you choose the installation path just now? Why choose now?

Let me explain here, maybe careful friends have discovered that when the path was selected just now, the default path is: C:\Porgram File\Java\jdk1.8.0_181

The default path here is: C:\Porgram File\Java\jre1.8.0_181

That is to say, JDK (development) was installed just now, and JRE (running) is installed now. The path suggestion is to install these two in the same directory. That is to say, if the first path selection is: X:\aaa\bbb\jdk1.8.0_181

The second installation path is best: X:\aaa\bbb\jre1.8.0_181 This is for the convenience of writing environment variable values.

Next, click Next until the final installation is complete (pirated image)


Open System Settings, click Advanced Program Settings

Then click on Environment Variables

After opening the environment variable interface, click New at the bottom (note: the new button of the system variable below)

JAVA_HOME variable

Create a new JAVA_HOME variable (can be copied below)

_HOME

Click to browse the directory and find the path you changed for the first time during the installation (the unmodified default path is C:\Program Files\Java\jdk1.8.0_181)

(My installation is relatively early, so the picture shows jdk1.8.0_161)

Then click OK. (Note: After clicking OK, check to make sure this variable is configured)

Path variable

Find the path variable in the system variable, select it, and click Edit

Then click New (you can copy it below, it has nothing to do with the previous path)

%JAVA_HOME%\bin

Continue to click New, in order to ensure that jre (running) does not cause problems when you use javaIDE, create a new variable

%JAVA_HOME%\jre\bin

Note again: it must be all characters in English.

Click OK, then OK. Open the path variable to confirm whether the variable has been successfully saved.

ClassPath variable

The method is the same as java-home, click New on the initial interface (you can copy it below)

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

Click OK, then close and reopen to confirm whether the installation has been successful.

Remarks: At present, the author is looking for a more accurate configuration value of the classpath variable environment. (There are various versions on the Internet) The basis for the configuration values ​​​​used in this article is explained below

At this point, the Java environment variables that everyone agrees on are configured. Do you understand?


Explanation of classpath variable configuration

Open the JDK directory in my computer and find the following files;

Open the file directory written by the classpath variable and find the following files.

Edit, create a series of values ​​​​into the system variable, in fact, it is equivalent to telling your computer that the operating environment of a programming language you newly installed is here, and you can guide your computer to the required folder through the configuration here Down. The JAVA language needs to run through a virtual machine, so the configuration environment variable is to guide the JAVA file to the folder you specify to run the virtual machine when it is running.

So, the configuration value of my java environment classpath variable is correct!

Verification of the java runtime environment

Press the Windows + R button on the keyboard to open the run prompt box, and enter cmd (command shorthand, open the "small black box")

Enter java to verify that the java installation is successful.

Type javac

click enter

Verification complete!

Guess you like

Origin blog.csdn.net/github_36665118/article/details/130646381