13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.3 The System Class105several successively executed programs. Some examples of envir<strong>on</strong>mentvariables 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 envir<strong>on</strong>ment variables defined in your current shell, type envat the command prompt:$ envHOME=/home/user01USER=user01PATH=/bin:/usr/bin:/usr/local/bin:/home/user01/bin...$The names of envir<strong>on</strong>ment variables, sometimes referred to as shell variables,are traditi<strong>on</strong>ally uppercase, though that is <strong>on</strong>ly a c<strong>on</strong>venti<strong>on</strong>. The variablenames are treated in a case sensitive fashi<strong>on</strong> (e.g., Home != HOME).You can set envir<strong>on</strong>ment variables for use in the current shell with a simpleassignment statement:$ VAR=valueThat will set the value for the durati<strong>on</strong> of this shell, but not for any of its subprocesses.Since running another program is a subprocess, such an assignmentw<strong>on</strong>’t be visible in your running program. Instead, you can export the variableso that it is carried forward to all subprocesses: 1$ export VAR=value4.3.3 Java and Envir<strong>on</strong>ment VariablesIf these envir<strong>on</strong>ment variables are available to all <strong>Linux</strong> processes, then how dowe get at them from a Java program? Well, we can’t do it quite as directly asyou might think. In previous (1.2 and older) versi<strong>on</strong>s of Java, the System class1. If you are using csh (the C-shell, another <strong>Linux</strong> command-line interpreter), then the syntaxis slightly different. Instead of export name=value use setenv name value (note thedifferent keyword and no equal sign).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!