Appearance
How to set the environment variables for Java in Windows
To set environment variables for Java in Windows:
- Press the Windows key + R on your keyboard to open the "Run" dialog.
- Type
controland press Enter. - In the Control Panel, click on "System and Security", then click on "System".
- In the left panel, click on "Advanced system settings".
- In the "System Properties" window, click on the "Environment Variables" button.
- Under the "System variables" section, scroll down and find the "Path" variable. Click on "Edit...".
- In the "Edit environment variable" window, click on "New" and enter the path to your Java installation directory (e.g.,
C:\Program Files\Java\jdk-17\bin). - 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:
- Open the command prompt by pressing the Windows key + R on your keyboard, typing
cmdand pressing Enter. - Type the following command and press Enter:
cmd
setx path "%path%;C:\Program Files\Java\jdk-17\bin" /MThis will add the path to your Java installation directory to the system "Path" environment variable. Note that the /M flag requires Administrator privileges.
- Close and reopen any open command prompts for the changes to take effect.