Home  >  Article  >  Java  >  How to configure Java environment variables in Windows operating system?

How to configure Java environment variables in Windows operating system?

WBOY
WBOYOriginal
2023-12-23 11:26:381192browse

How to configure Java environment variables in Windows operating system?

How to configure Java environment variables in Windows operating system?

The configuration of Java environment variables is very important for developers and system administrators. It can help us run Java programs correctly in Windows systems. The following are specific steps and code examples on how to configure Java environment variables in Windows systems.

  1. Download and install the Java Development Kit (JDK)

First, you need to download the Java Development Kit (JDK) for Windows systems from the official Oracle website. After the download is complete, follow the instructions of the installation wizard to install. After the installation is complete, remember the installation path because we will need it next.

  1. Find the environment variable configuration interface

In Windows systems, you can find the environment variable configuration interface through the following path:

  • Right-click "Computer" or "This PC", select "Properties";
  • Click "Advanced System Settings";
  • In the pop-up dialog box, select "Environment Variables".
  1. New system variables

In the environment variable configuration interface, find the "System Variables" section, click the "New" button, and add the following two system variables :

  • Variable name: JAVA_HOME

    • Variable value: JDK installation path, for example: C:Program FilesJavajdk1.8.0_301
  • Variable name: CLASSPATH

    • Variable value: .;%JAVA_HOME%lib;%JAVA_HOME%libdt.jar;%JAVA_HOME%lib ools.jar
  1. Modify the Path variable

Find the "Path" variable in the system variable list and click the "Edit" button. In the pop-up dialog box, add the following content to the end of the Path variable value:

  • %JAVA_HOME% in;%JAVA_HOME%jre in

Complete the above steps Finally, you have successfully configured the Java environment variables. Next, we should verify that the configuration was successful.

In order to verify whether the Java environment variable configuration is successful, we can open the command line interface and enter the following command:

java -version

If the configuration is correct, you will see output similar to the following:

java version "1.8.0_301"
Java(TM) SE Runtime Environment (build 1.8.0_301-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.301-b09, mixed mode)

The above are the specific steps and code examples for configuring Java environment variables in Windows systems. By correctly configuring Java environment variables, we can ensure that Java programs can run smoothly on Windows systems, making development work smoother and more efficient.

The above is the detailed content of How to configure Java environment variables in Windows operating system?. 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