An environment variable is a variable that stores a value that is used by an operating system or a process (application).
In this book, I will use Unix-style environment variables in examples. If you are using Windows, simply replace ${MY_VARIABLE}
with %MY_VARIABLE%
.
The method of setting environment variables is operating system dependent, but the format of creating and modifying environment variables is similar.
As an example, we will show how to add the JAVA_HOME
environment variable on both Linux and Windows operating systems. This example assumes that the JDK has been installed to ${HOME}/jdk1.7.0_25
on Linux and to C:\jdk1.7.0_25
on Windows.
Note
These are not appropriate installation locations for production systems; they are just intended to be used for experimentation and prototyping.
To set the JAVA_HOME
environment variable in a Linux system that uses the bash shell, add the following lines to the ${HOME}/.bashrc
file:
export JAVA_HOME=${HOME}/jdk1.7.0_25 export...