How to configure environment variables in Java

  • Download and install JDK
  • Configure environment variables
  • Check whether the Java runtime environment is configured successfully

1. JDK download and installation :
            Baidu directly searches for JDK, opens Oracle's jdk download page, and downloads and installs the appropriate JDK according to the system digits of your computer ( remember the JDK installation path , which will be used for subsequent configuration of environment variables )
download address (JDK8):
Java Downloads | Oracle https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

2. Configure environment variables
 1. Open the environment variable window: right-click My Computer -> Properties -> Advanced System Settings -> Environment Variables to enter the following realm
( or you can directly search and edit system environment variables through the search box )

 

 2. Click New to add a JAVA_HOME variable at the bottom of the system variable, the variable name is "JAVA_HONE", and the variable value is the path when the JDK is installed, and then click OK to create a new one successfully.


 3. Similarly, create/modify a CLASSPATH variable. This variable is special, and the variable name and variable value are fixed.

变量名为:ClassPath
变量值为:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
//变量值前方有一个 “.;” ,后方有一个“ ;”。

4. Modify the path variable, find the Path variable through the scroll wheel in the system variables , double-click to enter the editor of the path variable, and create two environment variables named " %JAVA_HOME%\bin " and " %JAVA_HOME%\jre\bin ".


 

 5. Click OK for all, since then, the Java environment variable configuration is complete

 

3. Check whether the Java operating environment is configured successfully:
        1. Verify by running the command: press the Windows + R key on the keyboard to open the running prompt box and enter cmd 

2. Click OK to enter the following interface:


3. Enter java -version and press Enter, if the following code (Java program version) appears, it means the configuration is successful.
Note: "java -version" has a space after Java, and then a bar "-". Many students can't display the result because they missed a space.

 

 

Guess you like

Origin blog.csdn.net/weixin_54645719/article/details/126196029