Java Reference
In-Depth Information
several successively executed programs. Some examples of environment
variables are:
USER is the name you used to log in.
HOME is the directory where you start when you log in.
PATH is the list of directories searched for executable files.
To see the environment variables defined in your current shell, type env
at the command prompt:
$ env
HOME=/home/user01
USER=user01
PATH=/bin:/usr/bin:/usr/local/bin:/home/user01/bin
...
$
The names of environment variables, sometimes referred to as shell vari-
ables , are traditionally uppercase, though that is only a convention. The variable
names are treated in a case sensitive fashion (e.g., Home != HOME ).
You can set environment variables for use in the current shell with a simple
assignment statement:
$ VAR=value
That will set the value for the duration of this shell, but not for any of its sub-
processes. Since running another program is a subprocess, such an assignment
won't be visible in your running program. Instead, you can export the variable
so that it is carried forward to all subprocesses: 1
$ export VAR=value
4.3.3
If these environment variables are available to all Linux processes, then how do
we get at them from a Java program? Well, we can't do it quite as directly as
you might think. In previous (1.2 and older) versions of Java, the System class
Java and Environment Variables
1. If you are using csh (the C-shell, another Linux command-line interpreter), then the syntax
is slightly different. Instead of export name=value use setenv name value (note the
different keyword and no equal sign).
Search WWH ::




Custom Search