o7planning

Setup environment variables on Windows

  1. Set up an environment variable
  2. PATH environment variable

1. Set up an environment variable

Press "WIN + R" to open the RUN window.
On the "RUN" dialog box, enter the command below:
rundll32.exe sysdm.cpl,EditEnvironmentVariables
Press the key combination "CTRL+SHIFT+ENTER" to open the "Environment Variables" window with maximum permissions. If you press the "OK" button the "Environment Variables" window is still opened but with limited permissions (You can modify user variables but cannot modify system variables).
Instead of pressing the "OK" button, press the key combination "CTRL+SHIFT+ENTER".
The "Environment Variables" window has just opened. Basically, in Windows there are 2 types of environment variables:
  • User Variables: Are environment variables used for the current user (you).
  • System Variables: Are environment variables that apply to all users.
For example, create a user variable. Click the "New" button to create a new one.
Enter the environment variable name and its value.
Click the "OK" button to save the changes, and open a CMD window to test the variable you just created.
C:\Users\karakol>echo %greeting%
Hello Everybody!

2. PATH environment variable

Path is an important environment variable in Windows operating systems as well as Linux and MacOS. It specifies the folders containing the executable programs installed on your computer. On CMD, you can briefly type the program name to execute it without having to type the full path.
For example, on CMD, to check Java version you have to type the full path of java like this:
C:\DevPrograms\Java\jdk-11.0.8\bin\java -version

# OR:

C:\DevPrograms\Java\jdk-11.0.8\bin\java.exe -version
Now just declare the directory containing the "java.exe" file in the Path environment variable:
Now, on CMD you can check the version of Java with a shorter command:
java -version