Java environment variable

While working with java development , it is a common need to set Java (JDK) path variable in the machine so that we can use it for Java related command line usage.

There are some confusions about user variable and system variable while setting the path for some of the people (specially beginners).

Every process has an environment block that contains a set of environment variables and their values.

There are two types of environment variables:
user environment variables (set for each user) and system environment variables (set for everyone).

A child process inherits the environment variables of its parent process by default.

System variables:

  • Programs started by the command processor inherit the command processor’s environment variables.
  • System Environment variables are those defined by system and are globally used by all users.
  • As the name suggests it deals with the environment of your computer or in more technical terms, the Operating System i.e. an environment the operating system provides the user to execute or perform various operations. So system environment variables provide the variables or values stored in the variables that are required by the system to let other applications perform their tasks.
  • By accessing these variables provided by the system you can get essential information about the system that could be helpful in many ways either to perform a task or to run some kind of program on the system.

User variables

  • User variables are only used by the user who declared that variable.
  • Users can create variables of their choice and insert in it the values that they desire. You can create your own “path” variable or you can even store a string in that variable.
  • You can access the user variables by simply typing the variable in ‘Run'(windows key+R) and it may take you to the path of the user defined variable. But you need to remember that you can not provide the path of any other user’s account as user variables are only accessible by the user who makes them.

Do User Variables Override System Variables?

  • User variables override the system Variables even if the variables are named the same.
  • However there is a slight difference in ‘PATH’ system variable, the user defined ‘path’ variable does not completely replace it. In fact, it appends with the system ‘PATH’ variable.


Leave a Reply