NOTE: On most unix-like operating systems like Mac OS X and Ubuntu Linux management of environment variables is handled for you by the package manager when you install new programs. So you should only have to worry about how to set up/change an environment variable if you are a Windows user.
An environment variable is a dynamically stored value that affect the way processes run on a computer. The only one that we need to be concerned about for this class is the Windows PATH environment variable. This environment variable is used by the Command Line to determine the directory locations of executable code to run when a command is given to it. The PATH environment variable just stored a bunch of file directory paths and every time Command Line is given a command it looks in the directories that the paths in the PATH environment variable point to in order to find the code to execute for the command it was given. For example, on Windows Command Line typing "dir" will list all the files and folders in directory that the Command Line is current in. Command Line does not know just from the 3 characters "dir" what it is supposed to do. The code to find and print out all that information is on your computer somewhere and the PATH environment variable by default in Windows will contain a path to a directory with a file called "dir.exe" (a Windows executable file). "dir.exe" contains the code that prints out the file names in the current directory. So when Command Line is given the command "dir" it searches the directories pointed to by the paths in PATH and then finds "dir.exe" and executes its code, which prints out the current directories file and folder names. When you want Command Line to recognize a new command, such as "java" or "javac", you have to modify the PATH environment variable in order to tell the Command Line where to look to find the executable file to run those commands.
CORRECTION: The example above, strictly speaking, is incorrect because "dir" is an internal command which Windows automatically recognizes without external files, and Command Line only needs to use the PATH environent variable for external commands (which are the ones we are concerned with). It was just an example. Check this out to learn more.
Here are a few resources if you want to learn more about environment variables:
NOTE: For the purposes of this class this section only applies to Windows users.
NOTE: These screenshots were taken on Windows 10. These instructions should be more or less the same for Windows 7 and 8. Here are some alternative instructions directly for Windows 7/8 if you need them.
NOTE: Look here for instructions on how to copy/paste a file/folder path on Windows.
NOTE: the Command Prompt only loads the environment variables on startup so you must close and reopen the Command Prompt in order for it to recognize the changes you've made to the PATH.
It is important that there is a semicolon (;) separating the folder that you add from the previous folder. For example, if your Path variable looks like this initially:
it should look like this after you add the new folder: