How to configure the JDK environment variables in Java?

To set up the JDK environment variable on a Windows operating system, the following steps are required:

  1. Download and install JDK: Start by downloading and installing the latest version of JDK. You can download the JDK installation package from the Oracle official website and then follow the installation wizard to complete the installation.
  2. To locate the JDK installation path: After installation, you will need to find the installation path for the JDK. Typically, the JDK is installed in the C:\Program Files\Java directory.
  3. To set the JAVA_HOME environment variable, go to system properties and set JAVA_HOME with the installation path of JDK as the variable value. Follow these specific steps:
  4. Right-click on “Computer” or “This PC”, and select “Properties”.
  5. Click on “Advanced System Settings”.
  6. Click on the “Environment Variables” button in the pop-up window.
  7. Click on “New” in the “System Variables” section, enter the variable name as “JAVA_HOME” and input the variable value as the installation path of JDK, for example “C:\Program Files\Java\jdk1.8.0_221”.
  8. Update the Path environment variable by adding the JDK’s bin directory to it, so that the system can locate Java executable files. The specific steps are as follows:
  9. Locate the “Path” variable in the system variables and click on “Edit”.
  10. Add “;%JAVA_HOME%\bin” to the end of the variable value, and then click “OK”.
  11. Configuration verification: Enter “java -version” and “javac -version” commands in the command line. If the Java version information is properly displayed, it means that the configuration is successful.

Once the configuration is complete, you can start developing Java programs using the command line or other development tools.

bannerAds