What is the name of the program file that you can enter in the Windows search

Environment variables are global system variables accessible by all the processes/users running under the Operating System (OS), such as Windows, macOS and Linux. Environment variables are useful to store system-wide values, for examples,

  • Display the value of the variable
    Set or change the value of the variable (Note: no space before and after '=')
    Delete the variable by setting to empty string (Note: nothing after '=')
    Display ALL the environment variables
    5: the most frequently-used environment variable, which stores a list of directories to search for executable programs.
  • Display the value of the variable
    Set or change the value of the variable (Note: no space before and after '=')
    Delete the variable by setting to empty string (Note: nothing after '=')
    Display ALL the environment variables
    6: the operating system.
  • Display the value of the variable
    Set or change the value of the variable (Note: no space before and after '=')
    Delete the variable by setting to empty string (Note: nothing after '=')
    Display ALL the environment variables
    7,
    Display the value of the variable
    Set or change the value of the variable (Note: no space before and after '=')
    Delete the variable by setting to empty string (Note: nothing after '=')
    Display ALL the environment variables
    8: stores the computer and current user name.
  • Display the value of the variable
    Set or change the value of the variable (Note: no space before and after '=')
    Delete the variable by setting to empty string (Note: nothing after '=')
    Display ALL the environment variables
    9: the system root directory.
  • (Windows)
    set VAR_NAME
    VAR_NAME=VAR_VALUE
    0,
    set VAR_NAME
    VAR_NAME=VAR_VALUE
    1: Current user's home directory.

(Windows) Environment Variables

Environment Variables in Windows are NOT case-sensitive (because the legacy DOS is NOT case-sensitive). They are typically named in uppercase, with words joined with underscore (

set VAR_NAME
VAR_NAME=VAR_VALUE
2), e.g.,
set VAR_NAME
VAR_NAME=VAR_VALUE
3.

Display Environment Variables and their Values

To list ALL the environment variables and their values, start a CMD and issue the command "

set VAR_NAME
VAR_NAME=VAR_VALUE
4", as follows,

Try issuing a "

set VAR_NAME
VAR_NAME=VAR_VALUE
4" command on your system, and study the environment variables listed. Pay particular attention to the variable called
Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5.

To display a particular variable, use command "

set VAR_NAME
VAR_NAME=VAR_VALUE
7", or "
set VAR_NAME
VAR_NAME=VAR_VALUE
8":

// Display a particular variable
set COMPUTERNAME
COMPUTERNAME=xxxxxx

// or, use "echo" command with variable name enclosed within a pair of '%'
echo %COMPUTERNAME%
COMPUTERNAME=xxxxxx

Set/Unset/Change an Environment Variable for the "Current" CMD Session

To set (or change) a environment variable, use command "

set VAR_NAME
VAR_NAME=VAR_VALUE
9". There shall be no spaces before and after the
// (Windows 2000/XP/Vista/7/8/10) "cmd.exe"
abc
'abc' is not recognized as an internal or external command,
operable program or batch file.
 
// (Windows 95/98) "command.com"
abc
Bad command or file name
0 sign. To unset an environment variable, use "
// (Windows 2000/XP/Vista/7/8/10) "cmd.exe"
abc
'abc' is not recognized as an internal or external command,
operable program or batch file.
 
// (Windows 95/98) "command.com"
abc
Bad command or file name
1", i.e., set it to an empty string.

set varname
set varname=value
set varname=
set
Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables

For examples,

An environment variable set via the "

set VAR_NAME
VAR_NAME=VAR_VALUE
4" command under CMD is a local, available to the current CMD session only. Try setting a variable, re-start CMD and look for the variable.

Using an Environment Variable

To reference a variable in Windows, use

// (Windows 2000/XP/Vista/7/8/10) "cmd.exe"
abc
'abc' is not recognized as an internal or external command,
operable program or batch file.
 
// (Windows 95/98) "command.com"
abc
Bad command or file name
3 (with prefix and suffix of
// (Windows 2000/XP/Vista/7/8/10) "cmd.exe"
abc
'abc' is not recognized as an internal or external command,
operable program or batch file.
 
// (Windows 95/98) "command.com"
abc
Bad command or file name
4). For example, you can use the
// (Windows 2000/XP/Vista/7/8/10) "cmd.exe"
abc
'abc' is not recognized as an internal or external command,
operable program or batch file.
 
// (Windows 95/98) "command.com"
abc
Bad command or file name
5 command to print the value of a variable in the form "
set VAR_NAME
VAR_NAME=VAR_VALUE
8".

How to Add or Change an Environment Variable "Permanently"

To add/change an environment variable permanently in Windows (so that it is available to ALL the Windows' processes/users and stayed across boots):

  1. Launch "Control Panel"
  2. "System"
  3. "Advanced system settings"
  4. Switch to "Advanced" tab
  5. "Environment variables"
  6. Choose "System Variables" (for all users)
  7. To add a new environment variable:
    1. Choose "New"
    2. Enter the variable "Name" and "Value". Instead of typing the "value" and making typo error, I suggest that you use "Browse Directory..." or "Browse File..." button to retrieve the desired directory or file.
  8. To change an existing environment variable:
    1. Choose "Edit"
    2. Enter the new "Value". Instead of typing the "value" and making typo error, I suggest that you use "Browse Directory..." or "Browse File..." button to retrieve the desired directory or file.

You need to RE-START CMD for the new setting to take effect!

To verify the new setting, launch CMD:

set VAR_NAME
VAR_NAME=VAR_VALUE

PATH Environment Variable in Windows

When you launch an executable program (with file extension of "

// (Windows 2000/XP/Vista/7/8/10) "cmd.exe"
abc
'abc' is not recognized as an internal or external command,
operable program or batch file.
 
// (Windows 95/98) "command.com"
abc
Bad command or file name
7", "
// (Windows 2000/XP/Vista/7/8/10) "cmd.exe"
abc
'abc' is not recognized as an internal or external command,
operable program or batch file.
 
// (Windows 95/98) "command.com"
abc
Bad command or file name
8" or "
// (Windows 2000/XP/Vista/7/8/10) "cmd.exe"
abc
'abc' is not recognized as an internal or external command,
operable program or batch file.
 
// (Windows 95/98) "command.com"
abc
Bad command or file name
9") from the CMD shell, Windows searches for the executable program in the current working directory, followed by all the directories listed in the
Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5 environment variable. If the program cannot be found in these directories, you will get the following error:

// (Windows 2000/XP/Vista/7/8/10) "cmd.exe"
abc
'abc' is not recognized as an internal or external command,
operable program or batch file.
 
// (Windows 95/98) "command.com"
abc
Bad command or file name

To list the current

Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5, issue command:

PATH
PATH=path1;path1;path3;...

How to Add a Directory to the PATH in Windows

To add a directory to the existing

Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5 in Windows:

  1. Launch "Control Panel"
  2. "System"
  3. "Advanced system settings"
  4. Switch to "Advanced" tab
  5. "Environment variables"
  6. Under "System Variables" (for all users), select "Path"
  7. "Edit"
  8. (For newer Windows 10) A table pops up showing the directories included in the current PATH setting ⇒ "New" ⇒ "Browse..." to select the desired directory to be added to the PATH (Don't type as you will make typo error!) ⇒ Click "Move Up" repeatedly to move it to the top ⇒ "OK" (Don't "Cancel") ⇒ "OK" ⇒ "OK".
  9. (For older Windows) If you didn't see a pop-up table, it is time to change your computer.

You need to RE-START CMD for the new PATH setting to take effect!

To verify the new setting, launch CMD:

PATH
PATH=path1;path2;path3;...

Notes:

  • Windows searches the current directory (
    PATH
    PATH=path1;path1;path3;...
    3) before searching the
    Display the value of the variable
    Set or change the value of the variable (Note: no space before and after '=')
    Delete the variable by setting to empty string (Note: nothing after '=')
    Display ALL the environment variables
    5 entries. (Unixes/macOS does not search the current directory, unless you include it in the PATH explicitly.)
  • Windows uses semicolon (
    PATH
    PATH=path1;path1;path3;...
    5) as the path separator; while Unixes/macOS uses colon (
    PATH
    PATH=path1;path1;path3;...
    6).
  • If your directory name contains special characters such as space (strongly not recommended), enclosed it with double quotes.

(macOS/Linux) Environment Variables

Environment variables in macOS/Unixes are case-sensitive. Global environment variables (available to ALL processes) are named in uppercase, with words joined with underscore (

set VAR_NAME
VAR_NAME=VAR_VALUE
2), e.g.,
set VAR_NAME
VAR_NAME=VAR_VALUE
3. Local variables (available to the current process only) are in lowercase.

Using Environment Variables in Bash Shell

Most of the Unixes (Ubuntu/macOS) use the so-called Bash shell. Under

PATH
PATH=path1;path1;path3;...
9 shell:

  • To list all the environment variables, use the command "
    PATH
    PATH=path1;path2;path3;...
    0" (or "
    PATH
    PATH=path1;path2;path3;...
    1"). You could also use "
    set VAR_NAME
    VAR_NAME=VAR_VALUE
    4" to list all the variables, including all local variables.
  • To reference a variable, use
    PATH
    PATH=path1;path2;path3;...
    3, with a prefix
    PATH
    PATH=path1;path2;path3;...
    4 (Windows uses
    // (Windows 2000/XP/Vista/7/8/10) "cmd.exe"
    abc
    'abc' is not recognized as an internal or external command,
    operable program or batch file.
     
    // (Windows 95/98) "command.com"
    abc
    Bad command or file name
    3).
  • To print the value of a particular variable, use the command "
    PATH
    PATH=path1;path2;path3;...
    6".
  • To set an environment variable, use the command "
    PATH
    PATH=path1;path2;path3;...
    7", which sets the variable and exports it to the global environment (available to other processes). Enclosed the value with double quotes if it contains spaces.
  • To set a local variable, use the command "
    PATH
    PATH=path1;path2;path3;...
    8
    PATH
    PATH=path1;path2;path3;...
    9" (or "
    set VAR_NAME
    VAR_NAME=VAR_VALUE
    4
    PATH
    PATH=path1;path2;path3;...
    8
    PATH
    PATH=path1;path2;path3;...
    9"). Local variable is available within this process only.
  • To unset a local variable, use command "
    PATH
    PATH=path1;path2;path3;...
    8
    export CLASSPATH=.:/usr/local/tomcat/lib/servlet-api.jar
    4", i.e., set to empty string (or "
    export CLASSPATH=.:/usr/local/tomcat/lib/servlet-api.jar
    5
    PATH
    PATH=path1;path2;path3;...
    8").

How to Set an Environment Variable Permanently in Bash Shell

You can set an environment variable permanently by placing an

export CLASSPATH=.:/usr/local/tomcat/lib/servlet-api.jar
7 command in your Bash shell's startup script "
export CLASSPATH=.:/usr/local/tomcat/lib/servlet-api.jar
8" (or
export CLASSPATH=.:/usr/local/tomcat/lib/servlet-api.jar
9", or "
// Refresh the bash shell
source ~/.bashrc
// or
source ~/.bash_profile
source ~/.profile
source /etc/profile
0") of your home directory; or "
// Refresh the bash shell
source ~/.bashrc
// or
source ~/.bash_profile
source ~/.profile
source /etc/profile
1" for system-wide operations. Take note that files beginning with dot (
PATH
PATH=path1;path1;path3;...
3) is hidden by default. To display hidden files, use command "
// Refresh the bash shell
source ~/.bashrc
// or
source ~/.bash_profile
source ~/.profile
source /etc/profile
3" or "
// Refresh the bash shell
source ~/.bashrc
// or
source ~/.bash_profile
source ~/.profile
source /etc/profile
4".

For example, to add a directory to the

Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5 environment variable, add the following line at the end of
// Refresh the bash shell
source ~/.bashrc
// or
source ~/.bash_profile
source ~/.profile
source /etc/profile
6" (or
export CLASSPATH=.:/usr/local/tomcat/lib/servlet-api.jar
9", or "
// Refresh the bash shell
source ~/.bashrc
// or
source ~/.bash_profile
source ~/.profile
source /etc/profile
0"), where
// Refresh the bash shell
source ~/.bashrc
// or
source ~/.bash_profile
source ~/.profile
source /etc/profile
9 denotes the home directory of the current user, or "
// Refresh the bash shell
source ~/.bashrc
// or
source ~/.bash_profile
source ~/.profile
source /etc/profile
1" for ALL users.

(For Java) You can set the

abc
bash: abc: command not found
1 environment variables by adding the following line. For example,

export CLASSPATH=.:/usr/local/tomcat/lib/servlet-api.jar

Take note that Bash shell uses colon (

PATH
PATH=path1;path1;path3;...
6) as the path separator; while windows use semicolon (
PATH
PATH=path1;path1;path3;...
5).

To refresh the bash shell, issue a "

abc
bash: abc: command not found
4" command (or re-start the bash shell):

// Refresh the bash shell
source ~/.bashrc
// or
source ~/.bash_profile
source ~/.profile
source /etc/profile

(Notes) For the older csh (C-shell) and ksh (Korn-shell)

  • Use "
    PATH
    PATH=path1;path2;path3;...
    1" (or "
    PATH
    PATH=path1;path2;path3;...
    0") to list all the environment variables.
  • Use "
    abc
    bash: abc: command not found
    7" and "
    abc
    bash: abc: command not found
    8" to set and unset an environment variable.
  • Use "
    set VAR_NAME
    VAR_NAME=VAR_VALUE
    9" and "
    set varname
    set varname=value
    set varname=
    set
    00" to set and unset a local variable for the current process.

PATH Environment Variable

Most of the Unixes and macOS use the so-called Bash Shell in the "Terminal". When you launch an executable program (with file permission of executable) in a Bash shell, the system searches the program in ALL the directories listed in the

Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5. If the program cannot be found, you will get the following error:

abc
bash: abc: command not found

Take note that the current directory (

PATH
PATH=path1;path1;path3;...
3) is not searched, unless it is included in the
Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5. To run a program in the current directory, you need to include the current path (
set varname
set varname=value
set varname=
set
04), for example,

set varname
set varname=value
set varname=
set
0

To list the current

Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5, issue command:

set varname
set varname=value
set varname=
set
1

How to Add a Directory to the PATH in macOS/Linux

To add a directory to the existing

Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5 in macOS/Unixes, add the following line at the end of one of the startup scripts, such as
// Refresh the bash shell
source ~/.bashrc
// or
source ~/.bash_profile
source ~/.profile
source /etc/profile
6", "
set varname
set varname=value
set varname=
set
08"
export CLASSPATH=.:/usr/local/tomcat/lib/servlet-api.jar
9", "
// Refresh the bash shell
source ~/.bashrc
// or
source ~/.bash_profile
source ~/.profile
source /etc/profile
0" (where
// Refresh the bash shell
source ~/.bashrc
// or
source ~/.bash_profile
source ~/.profile
source /etc/profile
9 denotes the home directory of the current user) or "
// Refresh the bash shell
source ~/.bashrc
// or
source ~/.bash_profile
source ~/.profile
source /etc/profile
1" for ALL users.

To refresh the bash shell, issue a "

abc
bash: abc: command not found
4" command (or re-start the bash shell):

// Refresh the bash shell
source ~/.bashrc
// or
source ~/.bash_profile
source ~/.profile
source /etc/profile

To verify the new setting, launch CMD:

set varname
set varname=value
set varname=
set
1

Notes:

  • Unixes/macOS does not search the current directory (
    PATH
    PATH=path1;path1;path3;...
    3), unless you include it explicitly in the
    Display the value of the variable
    Set or change the value of the variable (Note: no space before and after '=')
    Delete the variable by setting to empty string (Note: nothing after '=')
    Display ALL the environment variables
    5. In other words, to run a program in the current directory, you need to provide the directory (
    set varname
    set varname=value
    set varname=
    set
    04), for example,
    set varname
    set varname=value
    set varname=
    set
    0You could include the current directory in the
    Display the value of the variable
    Set or change the value of the variable (Note: no space before and after '=')
    Delete the variable by setting to empty string (Note: nothing after '=')
    Display ALL the environment variables
    5, by adding this line in a startup script: (Windows searches the current directory (
    PATH
    PATH=path1;path1;path3;...
    3) automatically before searching the PATH.)
  • Unixes/macOS uses colon (
    PATH
    PATH=path1;path1;path3;...
    6) as the path separator; while Windows uses semicolon (
    PATH
    PATH=path1;path1;path3;...
    5).

Java Applications and the Environment Variables PATH, CLASSPATH, JAVA_HOME

Many problems in the installation and running of Java applications are caused by incorrect setting of environment variables (global system variables available to all the processes/users running under the Operating System), in particular,

Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5,
abc
bash: abc: command not found
1 and
set VAR_NAME
VAR_NAME=VAR_VALUE
3.

When you launch a program from the command line, the Operating System uses the

Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5 environment variable to search for the program in your local file system. In other words,
Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5 maintains a list of directories for searching executable programs.

PATH (For Windows)

When you launch an executable program (with file extension of "

// (Windows 2000/XP/Vista/7/8/10) "cmd.exe"
abc
'abc' is not recognized as an internal or external command,
operable program or batch file.
 
// (Windows 95/98) "command.com"
abc
Bad command or file name
7", "
// (Windows 2000/XP/Vista/7/8/10) "cmd.exe"
abc
'abc' is not recognized as an internal or external command,
operable program or batch file.
 
// (Windows 95/98) "command.com"
abc
Bad command or file name
8" or "
// (Windows 2000/XP/Vista/7/8/10) "cmd.exe"
abc
'abc' is not recognized as an internal or external command,
operable program or batch file.
 
// (Windows 95/98) "command.com"
abc
Bad command or file name
9") from the CMD shell, Windows searches for the executable program in the current working directory, followed by all the directories listed in the
Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5 environment variable. If the program cannot be found in these directories, you will get the following error:

// (Windows 2000/XP/Vista/7/8/10) "cmd.exe"
abc
'abc' is not recognized as an internal or external command,
operable program or batch file.
 
// (Windows 95/98) "command.com"
abc
Bad command or file name

For example, if you are trying to use Java Compiler "

set varname
set varname=value
set varname=
set
30" to compile a Java source file, but "
set varname
set varname=value
set varname=
set
30" cannot be found in the current directory and all the directories in the
Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5, you will receive the following error:

set varname
set varname=value
set varname=
set
6

Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5 maintains a list of directories. The directories are separated by semicolon (
PATH
PATH=path1;path1;path3;...
5) in Windows.

For Java applications,

Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5 must include the following directories:

  • JDK's "
    set varname
    set varname=value
    set varname=
    set
    36" (binary) directory (e.g., "
    set varname
    set varname=value
    set varname=
    set
    37"), which contains JDK programs such as Java Compiler "
    set varname
    set varname=value
    set varname=
    set
    30" and Java Runtime "
    set varname
    set varname=value
    set varname=
    set
    39".
  • "
    set varname
    set varname=value
    set varname=
    set
    40" and "
    set varname
    set varname=value
    set varname=
    set
    41" which contain console programs and commands.

The JDK's "

set varname
set varname=value
set varname=
set
36" directory should be listed before "
set varname
set varname=value
set varname=
set
40" and "
set varname
set varname=value
set varname=
set
41" in the
Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5. This is because some older Windows systems provide their own Java runtime (which is often outdated) in these directories (try search for "
set varname
set varname=value
set varname=
set
39" in your computer, you may find a few entries).

To add a directory (say JDK's "

set varname
set varname=value
set varname=
set
36") to the existing PATH, check "How to add a directory to the PATH".

PATH (For macOS/Linux)

Most of the Unixes and macOS use the so-called Bash Shell in the "Terminal". When you launch an executable program (with file permission of executable) in a Bash shell, the system searches the program in ALL the directories listed in the

Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5. If the program cannot be found, you will get the following error:

abc
bash: abc: command not found

For example, if you are trying to use Java Compiler "

set varname
set varname=value
set varname=
set
49" to compile a Java source file, but "
set varname
set varname=value
set varname=
set
49" can not be found in the list of directories in the
Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5, you will receive the following error:

set varname
set varname=value
set varname=
set
8

To support Java applications, you need to include the JDK's "

set varname
set varname=value
set varname=
set
36" (binary) directory in the PATH. See "How to add a directory to the PATH".

Java Archive (JAR) File

For ease of distribution, Java classes are often archived (zipped) together into a so-called JAR file. To use a third-party Java package, you need to place the distributed JAR file in a location that is available to the Java Compiler and Java Runtime.

How Classes are Found?

Java Compiler ("

set varname
set varname=value
set varname=
set
49"), Java Runtime ("
set varname
set varname=value
set varname=
set
54") and other Java tools searches for classes used in your program in this order:

  1. Java platform (bootstrap) classes: include system classes in core packages (
    set varname
    set varname=value
    set varname=
    set
    55) and extension packages (
    set varname
    set varname=value
    set varname=
    set
    56) in "
    set varname
    set varname=value
    set varname=
    set
    57" (runtime class), "
    set varname
    set varname=value
    set varname=
    set
    58" (internationalization class),
    set varname
    set varname=value
    set varname=
    set
    59,
    set varname
    set varname=value
    set varname=
    set
    60, and others.
  2. Java Extension Directories: You can copy the external JAR files into Java Extension Directory (This is removed and not applicable from JDK 10).
    • For Windows, the Java Extension Directory is located at "
      set varname
      set varname=value
      set varname=
      set
      61" (e.g., "
      set varname
      set varname=value
      set varname=
      set
      62").
    • For macOS, the JDK extension directories are "
      set varname
      set varname=value
      set varname=
      set
      63" and "
      set varname
      set varname=value
      set varname=
      set
      64".
    • For Ubuntu, the JDK extension directories are "
      set varname
      set varname=value
      set varname=
      set
      65" (e.g., "
      set varname
      set varname=value
      set varname=
      set
      66") and "
      set varname
      set varname=value
      set varname=
      set
      67".
    The location of Java's Extension Directories is kept in Java's System Property "
    set varname
    set varname=value
    set varname=
    set
    68". You can print its contents via
    set varname
    set varname=value
    set varname=
    set
    69.
  3. User classes search path (in short, class path): determined in the following order:
    1. Defaulted to the current working directory (
      PATH
      PATH=path1;path1;path3;...
      3).
    2. Entries in the
      abc
      bash: abc: command not found
      1 environment variable, which overrides the default.
    3. Entries in the
      set varname
      set varname=value
      set varname=
      set
      72 (or
      set varname
      set varname=value
      set varname=
      set
      73) command-line option, which overrides the
      abc
      bash: abc: command not found
      1 environment variable.
    4. The runtime command-line option
      set varname
      set varname=value
      set varname=
      set
      75, which override all the above.
    The user class paths are kept in Java System property "
    set varname
    set varname=value
    set varname=
    set
    76".
    It is recommended that you use the
    set varname
    set varname=value
    set varname=
    set
    72 (or
    set varname
    set varname=value
    set varname=
    set
    73) command-line option (customized for each of your applications), instead of setting a permanent
    abc
    bash: abc: command not found
    1 environment for all the Java applications. IDE (such as Eclipse/NetBeans) manages
    set varname
    set varname=value
    set varname=
    set
    72 (
    set varname
    set varname=value
    set varname=
    set
    73) for each of the applications and does not rely on the
    abc
    bash: abc: command not found
    1 environment.
Cannot Find Classes

If the Java Runtime ("

set varname
set varname=value
set varname=
set
54") cannot find the classes used in your program in all the above places, it will issue error "Could not find or load main class xxxx" (JDK 1.7) or "java.lang.NoClassDefFoundError" (Prior to JDK 1.7).

Similarly, Java Compiler ("

set varname
set varname=value
set varname=
set
49") will issue compilation errors such as "cannot find symbol", "package does not exist".

Notes: External native libraries ("

set varname
set varname=value
set varname=
set
85", "
set varname
set varname=value
set varname=
set
86", "
set varname
set varname=value
set varname=
set
87", "
set varname
set varname=value
set varname=
set
88") are to be found in a path in JRE's Property "
set varname
set varname=value
set varname=
set
89", which normally but not necessarily includes all the directories in the
Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5 environment variable. Otherwise, you will get a runtime error "
set varname
set varname=value
set varname=
set
91".

CLASSPATH Environment Variable

The

abc
bash: abc: command not found
1 environment variable could include directories (containing many class files) and JAR files (a single-file archive of class files). If
abc
bash: abc: command not found
1 is not set, it is defaulted to the current directory. If you set the
abc
bash: abc: command not found
1, it is important to include the current working directory (
PATH
PATH=path1;path1;path3;...
3). Otherwise, the current directory will not be searched.

A common problem in running hello-world program is:

abc
bash: abc: command not found
1 is set but does not include the current working directory. The current directory is therefore not searched, which results in "Error: Could not find or load main class Hello". You can simply remove the
abc
bash: abc: command not found
1, and leave the class path defaulted to the current directory.

For a beginner, no explicit

abc
bash: abc: command not found
1 setting is required. The default
abc
bash: abc: command not found
1 setting of current directory is sufficient. Remove all
abc
bash: abc: command not found
1 setting if there is any. However, if you have to set
abc
bash: abc: command not found
1, make sure that you include the current directory
Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
02.

The

Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
5 environment variable (for searching the executable programs) is applicable to all applications; while
abc
bash: abc: command not found
1 is used by Java only.

Read JDK documents "Setting the

abc
bash: abc: command not found
1" and "How Classes are Found" (you can find the hyperlinks from the index page of the JDK documentation, or googling).

CLASSPATH Environment Variable (For Windows)

The

abc
bash: abc: command not found
1 accepts directories and jar-files. Path entries are separated by semicolon (
PATH
PATH=path1;path1;path3;...
5).

Example: Displaying and changing

abc
bash: abc: command not found
1 for the current CMD session.

You can set the

abc
bash: abc: command not found
1 permanently. See "How to Set an Environment Variable".

CLASSPATH (for macOS/Ubuntu)
  1. To set the
    abc
    bash: abc: command not found
    1 for the current session, issue this command:
    set varname
    set varname=value
    set varname=
    set
    9Use colon '
    PATH
    PATH=path1;path1;path3;...
    6' as the path separator (instead of semicolon '
    PATH
    PATH=path1;path1;path3;...
    5' in Windows).
  2. To set the
    abc
    bash: abc: command not found
    1 permanently, place the above export command in the bash shell initialization script (
    Display the value of the variable
    Set or change the value of the variable (Note: no space before and after '=')
    Delete the variable by setting to empty string (Note: nothing after '=')
    Display ALL the environment variables
    14 or
    Display the value of the variable
    Set or change the value of the variable (Note: no space before and after '=')
    Delete the variable by setting to empty string (Note: nothing after '=')
    Display ALL the environment variables
    15 of the home directory or
    // Refresh the bash shell
    source ~/.bashrc
    // or
    source ~/.bash_profile
    source ~/.profile
    source /etc/profile
    1 for all users). See "How to Set an Envrionment Variable".

JAVA_HOME and JRE_HOME

Many Java applications (such as Tomcat) require the environment variable

set VAR_NAME
VAR_NAME=VAR_VALUE
3 to be set to the JDK installed directory.

How to Set JAVA_HOME in Windows

First, check if

set VAR_NAME
VAR_NAME=VAR_VALUE
3 is already set by start a CMD and issue:

Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
0

If

set VAR_NAME
VAR_NAME=VAR_VALUE
3 is not set, you will receive "Environment variable JAVA_HOME not defined". Otherwise, the current setting will be shown.

To set/change

set VAR_NAME
VAR_NAME=VAR_VALUE
3 in Windows:

  1. Launch "Control Panel"
  2. "System"
  3. "Advanced system settings"
  4. Switch to "Advanced" tab
  5. "Environment variables"
  6. Choose "System Variables" (for all users)
  7. To add a new environment variable "
    set VAR_NAME
    VAR_NAME=VAR_VALUE
    3":
    1. Choose "New"
    2. In "Variable Name", enter "JAVA_HOME".
    3. In "Variable Value", click "Browse Directory..." and navigate to the JDK installed directory (e.g., "
      Display the value of the variable
      Set or change the value of the variable (Note: no space before and after '=')
      Delete the variable by setting to empty string (Note: nothing after '=')
      Display ALL the environment variables
      22").
    4. OK ⇒ OK ⇒ OK.
  8. To change the existing "
    set VAR_NAME
    VAR_NAME=VAR_VALUE
    3" setting:
    1. Select "
      set VAR_NAME
      VAR_NAME=VAR_VALUE
      3" ⇒ "Edit"
    2. In "Variable Value", click "Browse Directory..." and navigate to the JDK installed directory (e.g., "
      Display the value of the variable
      Set or change the value of the variable (Note: no space before and after '=')
      Delete the variable by setting to empty string (Note: nothing after '=')
      Display ALL the environment variables
      22").
    3. OK ⇒ OK ⇒ OK.

You need to RE-START CMD for the new setting to take effect!

To verify the new setting, re-start CMD:

Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
1
How to Set JAVA_HOME in Linux/macOS (Bash Shell)

First, check if

set VAR_NAME
VAR_NAME=VAR_VALUE
3 is already set by start a terminal and issue:

Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
2

set VAR_NAME
VAR_NAME=VAR_VALUE
3 is to be set to the JDK installed directory. You need to find your JDK installed directory.

[TODO] find macOS and Ubuntu JDK installed directory.

Add the the following line at the end of

// Refresh the bash shell
source ~/.bashrc
// or
source ~/.bash_profile
source ~/.profile
source /etc/profile
6" (or "
set varname
set varname=value
set varname=
set
08"). Take note that filename beginning with dot (
PATH
PATH=path1;path1;path3;...
3) is hidden by default.

[TODO] How to un-hide for macOS/Ubuntu.

Display the value of the variable
Set or change the value of the variable (Note: no space before and after '=')
Delete the variable by setting to empty string (Note: nothing after '=')
Display ALL the environment variables
3

You need to refresh the bash shell for the new settings to take effect. Issue a "

abc
bash: abc: command not found
4" command as follows:

What is the name of the program file that you can enter in the Windows Search box to execute event viewer?

Way 2: Turn on Event Viewer via Run. Press Windows+R to open the Run dialog, enter eventvwr (or eventvwr. msc) and hit OK.

What is Windows Search application?

Windows Search is a desktop search platform that has instant search capabilities for most common file types and data types, and third-party developers can extend these capabilities to new file types and data types.

What is Windows Search Windows 7?

The Search feature of Windows 7 allows you to search your hard drive for files. Note: It will not search through HTML files. Open the Start Menu. Enter the the file name you are searching for in the Search field.