Class SysEnv
java.lang.Object
com.sun.javatest.util.SysEnv
A class to provide access to OS environment variables, by means of
an external command which is executed.
The command will be executed when the first access is made to the environment variables. The command name is determined as follows:
- The value passed to setCommand, if that has been set
- The value of the system property "javatest.sysEnv.command", if that has been set
- An OS-specific default, if one is known. The current set of
defaults is as follows:
The current set of defaults OS Default Mac OS X /usr/bin/env Solaris /usr/bin/env Windows XP cmd /c set - Finally, a simple default of "env" is used. While this may not always work by default, a user could provide a suitable script or batch file on the current execution path that will yield the required results.
Note that the specified command will be invoked by Runtime.exec and must be capable or working as such. This may preclude direct use of builtin commands on some systems. For example, you cannot directly exec the Windows "set" command built in to the standard Windows command shell.
The command must print out a series of lines of the form name=value, one for each environment variable.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringGet the value of a specified environment value.getAll()Get a map containing all of the environment variables in the current execution context.Get a map containing all of the environment variables in the current execution context.static voidsetCommand(String cmd) Set the command to be executed to access the OS environment variables.
-
Constructor Details
-
SysEnv
public SysEnv()
-
-
Method Details
-
setCommand
Set the command to be executed to access the OS environment variables. To be effective, this method must be set before any of the get methods,- Parameters:
cmd- the command to be executed
-
get
-
getAll
-
getAll
Get a map containing all of the environment variables in the current execution context.- Parameters:
m- the map in which to put the names and values of all the environment variables in the current execution context.- Returns:
- the argument map.
-