Java configuration environment variables -- detailed articles

 

JAVA configuration environment variables in detail

Because of the computer system failure, I reinstalled the system, and then I needed to reconfigure the environment variables. I wanted to learn java for more than two years. Configuring an environment variable is not a piece of cake, but it was a big deal when I started to configure it. After a long time, I searched a lot of online information before configuring the environment variables. I was very emotional. Configuring environment variables seems simple, but there are many small details to pay attention to. Sometimes it will get stuck for a long time if you are not careful, so in Here is a summary of the knowledge of configuring environment variables, and the details are listed, hoping to help other beginner JAVA learners (it is recommended to read other configuration tutorials with pictures first, if the configuration is unsuccessful, see this post)

1. Go to oracle's official website to download JDK, click install after downloading (remember to download the complete jdk, not just jre, otherwise the configuration environment variables will not be able to be carried out later, note the installation directory here), after the installation is complete cmd command —> java or java -version to see if the installation is successful (no semicolon after java -version, otherwise the version information cannot be read).

 

2. Configure environment variables: mainly operate on the three environment variables in the system variables (I use win10 here):

My Computer - Properties - Advanced System Settings - System Variables

1. JAVA_HOME (create a new one if you don't have it), value: D:\JavaSdk (the installation directory for installing jdk yourself, this is mine, don't enter spaces)

2. If there is no CLASSPATH, create a new value: .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar; (No less than one character, including the preceding period, and the following semicolon) 

3. Path: Add ;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin; at the end of a long string of variable values ​​in Path (before adding, see if there is a semicolon at the end of the previous variable, between the environment variables It should be separated by semicolon. If there is already one, just remove one semicolon in front of this string of characters, and don't remove the latter one)

 

3. Check whether the configuration is successful. After the jdk is successfully installed, entering java or java -version in the console (cmd) can display a large series of information. The real way to check whether the environment variables are installed successfully is  

  Javac command, if there is a lot of information, the installation is successful, and if the configuration fails, it will prompt that 'javac' is not an internal or external command. So be careful when configuring.

 

4. Summary of configuration points: The configuration of environment variables seems simple, but there are many small details that need to be paid attention to. If you are not careful, the configuration may fail, so you should pay special attention.

    1. Point 1: Be sure to download JDK (including JRE) when downloading. If you accidentally download jre, the subsequent environment variable configuration cannot be configured successfully regardless of the correct method.

    2. Point 2: The configuration of environment variables is actually the configuration of three variables. The operations on these three variables are carried out in the system variables:

              The value of the JAVA_HOME variable is your jdk installation directory, which is installed in a directory such as Programfile on the c drive by default (the upper level of the bin directory, excluding the bin folder), so you must pay attention to your installation location when installing, do not follow the Copy the installation location of others online directly. The following variables are all references to the location of the JAVA_HOME variable, so this place cannot go wrong.

              Path variable, before entering the variable value, check whether there is a semicolon at the end of the previous variable. When editing the path variable, it is recommended to directly click the edit text and paste the code directly to the end. Do not create a new one directly on the interface, it is easy to add other characters.

    3. After editing the variables, be sure to click two confirmations to save and take effect, and then reopen the command console and input javac to test. It is to be closed and reopened. If it is still input on the original console, it is likely to fail. . This should also be a point that many people tend to miss, so keep it in mind!

   

 

5. Finally: Configuring environment variables is the first difficulty in getting started with java. Many java novices have been planted on it. As long as you are careful when configuring, there is no big problem.

                       

 

   Author: Four Swords

        

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325127249&siteId=291194637