Home  >  Article  >  How to configure jdk environment variables

How to configure jdk environment variables

zbt
zbtOriginal
2023-10-08 09:58:471535browse

jdk environment variable configuration steps: 1. Open the "Control Panel"; 2. Click "System and Security"; 3. Click "System"; 4. Click "Advanced System Settings"; 5. In the pop-up In the dialog box, click the "Environment Variables" button; 6. In the "System Variables" section, click the "New" button; 7. Enter "JAVA_HOME" in the "Variable Name" input box, and enter "JAVA_HOME" in the "Variable Value" input box. JDK installation path; 8. In the "System Variables" section, find the "Path" variable, click the "Edit" button, and so on.

How to configure jdk environment variables

JDK(Java Development Kit) is the abbreviation of Java Development Kit, which is the environment necessary to develop and compile Java applications. Before using JDK, we need to configure the JDK environment variables. This article will introduce how to configure JDK environment variables in Windows and Linux operating systems.

1. Configuring JDK environment variables in Windows operating system

In Windows operating system, there are two ways to configure JDK environment variables: through system properties and through the command line.

1. Configure JDK environment variables through system properties

The steps are as follows:

1. Open the "Control Panel".

2. Click "System and Security".

3. Click "System".

4. Click "Advanced System Settings".

5. In the pop-up dialog box, click the "Environment Variables" button.

6. In the "System Variables" section, click the "New" button.

7. Enter "JAVA_HOME" in the "Variable Name" input box, and enter the JDK installation path in the "Variable Value" input box, such as "C:\Program Files\Java\jdk1.8.0_221".

8. In the "System Variables" section, find the "Path" variable and click the "Edit" button.

9. In the "Variable Value" Add ";%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;" at the end of the input box.

10. Click the "OK" button to save the configuration.

2. Through the command line Configuring JDK environment variables

The steps are as follows:

1. Open the command prompt.

2. Enter the following command:

setx -m JAVA_HOME "C :\Program Files\Java\jdk1.8.0_221"

setx -m Path "%Path%;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;"

3. Press the Enter key to execute the command.

2. Configuring JDK environment variables in Linux operating system

In Linux operating system, configuring JDK environment variables requires editing the user’s home directory .bashrc file under.

The steps are as follows:

1. Open the terminal.

2. Enter the following command to edit the .bashrc file:

vi ~ /.bashrc

3. Add the following content at the end of the file:

export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_221

export PATH=$PATH :$JAVA_HOME/bin:$JAVA_HOME/jre/bin

4. Press the Esc key and enter: wq to save and exit the file.

5. Enter the following command to make the configuration effective:

source ~/.bashrc

Summary:

Configuring JDK environment variables is a prerequisite for using JDK for Java development. In Windows operating systems, you can Configure JDK environment variables through system properties or the command line; in the Linux operating system, you need to edit the .bashrc file to configure JDK environment variables. Correctly configuring JDK environment variables can ensure the normal operation of the Java development environment. I hope this article will be helpful to you !

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

Statement:
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