Home > Common Problem > How to configure environment variables after installing jdk

How to configure environment variables after installing jdk

zbt
Release: 2023-08-01 10:17:42
Original
3541 people have browsed it

Steps to configure environment variables after installing jdk: 1. Configure Path variables; 2. Configure CLASSPATH variables; 3. Test environment variable configuration.

How to configure environment variables after installing jdk

Install JDK (Java Development Kit) It is one of the basic steps in developing Java programs. After installing the JDK, we need to configure the environment variables so that the java and javac commands can be used in the command line window. This article will introduce how to configure JDK environment variables in Windows systems.

Before configuring the JDK environment variables, please ensure that the JDK has been successfully installed. You can download and install the latest JDK version from the Oracle official website. After the download is complete, install it through the installation wizard. After the installation is complete, you can find the JDK installation directory.

Preparation work:

Before configuring environment variables, you need to do some preparation work. First, open the "Start" menu, click "Computer", and then click "Properties". In the window that opens, click "Advanced system settings."

Next, in the pop-up "System Properties" window, click the "Environment Variables" button. In the "Environment Variables" window, we will configure the environment variables required by the JDK.

Configure JAVA_HOME variable:

In the user variable area, click the "New" button to create a new system variable. In the variable name input box, enter "JAVA_HOME". In the variable value input box, enter the installation path of the JDK.

For example, if the JDK installation directory is "C:\Program Files\Java\jdk1.8.0_271", enter the directory in the variable value input box. Then click the "OK" button to save the variable.

Configure the Path variable:

In the "Environment Variables" window, in the user variable area, find the system variable named "Path". Select this variable and click the "Edit" button.

In "Edit Variable Value" In the window, the cursor is located at the end of the input box. Enter an additional semicolon at the end of the input box, and then enter "%JAVA_HOME%\bin". Click the "OK" button to save the variable.

Configure the CLASSPATH variable:

In the "Environment Variables" window, in the user variable area, click the "New" button to create a new system variable. In the variable name input box, enter "CLASSPATH". In the variable value input box, enter ".;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar".

Click the "OK" button to save the variable.

At this point, we have configured the JDK environment variables. Next, we need to test whether the configuration is successful.

Test the environment variable configuration:

Open the command line window, enter the "java -version" command. If the environment variable is configured correctly, the JDK version information will be displayed.

Similarly, enter the "javac" command in the command line window. If the configuration is correct, the JDK version information will be displayed. Display the javac usage help information.

If you can see the JDK version information and javac usage help information, then congratulations, you have successfully configured the JDK environment variables.

Summary:

After installing the JDK, configuring environment variables is a very important step. Only when the environment variables are correctly configured can we use the java and javac commands in the command line window for development. Hope This article can help you successfully configure the JDK environment variables and start writing Java programs .

The above is the detailed content of How to configure environment variables after installing jdk. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template