“Environment variables” are just simple symbols that are available to any program; Windows uses these to to hold specific values. After the days of DOS we don’t usually need to be aware of them, but they’re still heavily used in Unix administration. We sometimes call them “environmental variables”.. same thing.
Here’s the skinny on setting an “environment variable” in Windows. As an example, let’s consider the PATH environment variable. This is used to tell Windows where to search to find the program that you entered, to execute it. You’ll want to set this if, for example, you’re setting up your system for compiling Java programs from the command-line.
Here I’ll illustrate using Windows XP. Windows Vista, Windows 7 and Windows 10 are similar enough that I don’t think you’ll have any trouble.
You’ll need to open the “System” Control-Panel applet, which you can do from the Control-Panel, or else just right-click on “My Computer” and select “Properties”.
Select the “Advanced” tab. You should see the System Properties dialog-window as shown in figure 1.
Click the button near the bottom that says “Environment Variables”. It should bring up the following dialog-window..
This shows your Environment Variables: those that are specific only to you (the current user) are in the upper list, and those that are system-wide are in the lower list.
Let’s set your path variable to include the directory where your Java compiler is located, to illustrate how to do this..
In the lower list, select the line that begins with “Path”. Click the “Edit” button. It should bring up this dialog..
Your Path variable consists of a multitude of file-system pathnames, separated by semicolons. You can append the pathname you want to add, simply be going to the end (click anywhere within the “Variable value:” textbox, then press your “End” key on your keyboard. Type a semicolon to separate your new value from what is already there, then type “C:\Java\JDK\bin” or whatever is appropriate for where you placed your JDK.
Click “OK”, and then “OK”, and you’re done.
If you already had a DOS Command-prompt window open, you’ll need to close it and re-open in order for your changes to affect it.
James W. Hurst