How to set the environment variables for Java in Windows

To set environment variables for Java in Windows:

  1. Press the Windows key + R on your keyboard to open the "Run" dialog.

  2. Type "control panel" and press Enter.

  3. In the Control Panel, click on "System and Security" and then click on "System".

  4. In the left panel, click on "Advanced system settings".

  5. In the "System Properties" window, click on the "Environment Variables" button.

  6. Under the "System variables" section, scroll down and find the "Path" variable. Click on "Edit...".

  7. In the "Edit environment variable" window, click on "New" and enter the path to your Java installation directory (e.g., "C:\Program Files\Java\jdk1.8.0_241\bin").

  8. Click "OK" to save the changes.

Note: You may need to close and reopen any open command prompts for the changes to take effect.

Alternatively, you can also set the environment variables for Java using the command prompt:

  1. Open the command prompt by pressing the Windows key + R on your keyboard, typing "cmd" and pressing Enter.

  2. Type the following command and press Enter:

setx path "%path%;C:\Program Files\Java\jdk1.8.0_241\bin"

This will add the path to your Java installation directory to the "Path" environment variable.

  1. Close and reopen any open command prompts for the changes to take effect.