Setting an environment variable in Windows

Hidden in the background(There is an updated edition of this post at

“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 assuming Windows XP (SP2). Vista is a bit different.

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.

The Advanced tab of the System Properties dialog

Click the button near the bottom that says “Environment Variables”. It should bring up the following dialog..

Setting the Environment Variables in Windows XP

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 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..

Setting the PATH variable for Java

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”.
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

About James W Hurst

a professional software architect and designer since the beginning days of the desktop cptr. Experienced in embedded (microcontrollers/electronics), desktop, server, mobile and web - I'm focusing on A.I. for solving difficult problems. My current language favorites are Rust and Go. Past experiences include C#, Python, R, C++, F#, JavaScript, Swift and Prolog, and desktop applications with Xamarin, WPF, UWP and Forms. My database expertise has covered a panoply of different database-engines and modeling approaches, and my main area of academic interest is Artificial Intelligence and vision.
This entry was posted in beginner, Microsoft Windows tips and techniques and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.