Because of the test environment under Linux, the sharing mechanism of variables in Linux environment:
About Export
1. The system environment variables in a shell are copied to the sub shell (with the variables defined by export).
2. The system environment variable in a shell is valid only for the shell or its child shell, and the variable disappears at the end of the shell (and cannot be returned to the parent shell).
3. A variable that is not defined by export is valid only for the shell, and the child shell is also invalid.
In Java, Java provides a static method of the System class getenv () and GetProperty () to return system-related variables and attributes when a program needs to use operating system-related variables such as file delimiters and line breaks. The variables returned by the Getenv method are mostly system-related, and the variables returned by the GetProperty method are mostly related to Java programs.
System Properties and environment variables are mappings between names and values. Both mechanisms can be used to pass user-defined information to the Java process. Environment variables produce more global effects because they are not only visible to Java child processes, but are visible to all child processes that define them. On different operating systems, their semantics are subtly different, for example, case-insensitive. Therefore, environment variables are more likely to have unexpected side effects. Use System properties as much as possible in your program. Environment variables should be used when global effects are required, or when external system interfaces require the use of environment variables (such as PATH).
How Java starts the subprocess:
Public Process exec (string[] cmdarray, string[] ENVP throws IOException executes the specified
command and arguments In a separate process with the specified environment.
Given an array of strings cmdarray, representing the tokens of-a command line, and an array of strings envp, representing "Environment" variable settings, this is creates a new process in which to execute the specified command.
<strong>if envp is null, the subprocess inherits the environment settings of the current process.</strong>
Ref:http://stackoverflow.com/questions/8997643/launch-a-child-process-from-java-that-doesnt-inherit-files-ports-on-unix