An environment variable is a dynamic “object” on a computer that stores a value, which in turn can be referenced by one or more software programs in Windows.
Environment variables are dynamic because they can change. The values they store can be changed to match the current computer system’s setup and design (environment). They can also differ between computer systems because each computer can have a different setup and design (environment).
Path specifies the directories in which executable programs are located on the machine that can be started without knowing and typing the whole path to the file on the command line.
After installing the software, the JDK directory will have the structure shown below.
bindirectory contains both the compiler and the launcher.
How to update PATH Environment Variable?
You can run Java applications just fine without setting the
PATH environment variable. Or, you can optionally set it as a convenience.
PATH environment variable if you want to be able to conveniently run the executables (
javadoc.exe, and so on) from any directory without having to type the full path of the command. If you do not set the
PATH variable, you need to specify the full path to the executable every time you run it, such as:
PATH environment variable is a series of directories separated by semicolons (
;). Microsoft Windows looks for programs in the
PATH directories in order, from left to right. You should have only one
bin directory for the JDK in the path at a time (those following the first are ignored), so if one is already present, you can update that particular entry.
The following is an example of a
PATH environment variable:
In order to view the value of
PATH environment variable, type the following command in command prompt window
It is useful to set the
PATH environment variable permanently so it will persist after rebooting. To make a permanent change to the
PATH variable, use the System icon in the Control Panel. The precise procedure varies depending on the version of Windows:
How to set PATH in Windows?
- From the desktop, right click the Computer icon.
- Choose Properties from the context menu.
- Click the Advanced system settings link.
- Click Environment Variables. In the section System Variables, find the
PATHenvironment variable and select it. Click Edit. If the
PATHenvironment variable does not exist, click
- In the Edit System Variable (or New System Variable) window, specify the value of the
PATHenvironment variable. Click OK. Close all remaining windows by clicking OK.
The CLASSPATH variable is one way to tell applications, including the JDK tools, where to look for user classes.
The preferred way to specify the class path is by using the -cp command line switch. This allows the CLASSPATH to be set individually for each application without affecting other applications.
The default value of the class path is “.”, meaning that only the current directory is searched. Specifying either the CLASSPATH variable or the -cp command line switch overrides this value.
To check whether CLASSPATH is set on Microsoft Windows , execute the following:
C:> echo %CLASSPATH%