[kepler-dev] [Bug 4152] - Modules should be able to add environment variables to the runtime

bugzilla-daemon at ecoinformatics.org bugzilla-daemon at ecoinformatics.org
Fri Jun 12 13:50:49 PDT 2009


http://bugzilla.ecoinformatics.org/show_bug.cgi?id=4152





------- Comment #3 from cxh at eecs.berkeley.edu  2009-06-12 13:50 -------
In Java 1.5 and later the java.lang.System.getEnv() method returns 
environment variables. 
The Javadoc for getEnv() says:

"System properties and environment variables are both conceptually mappings
between names and values. Both mechanisms can be used to pass user-defined
information to a Java process. Environment variables have a more global effect,
because they are visible to all descendants of the process which defines them,
not just the immediate Java subprocess. They can have subtly different
semantics, such as case insensitivity, on different operating systems. For
these reasons, environment variables are more likely to have unintended side
effects. It is best to use system properties where possible. Environment
variables should be used when a global effect is desired, or when an external
system interface requires an environment variable (such as PATH)."  

So, I think that if R is being invoked as a separate process or is running
a C call to getenv(), then we would need to set the environment variables.

The Java Process class can pass environment variables to subprocesses.

I don't think there is a Java setEnv() command.  One way to make this work
would be to define a Parameter that is a Record that could be referred to
by the External Execution actor (which uses ptolemy.actor.lib.Exec) in
the environment actor parameter.  This would allow subprocesses to 
access the updated environment variables.  I don't know if a JNI call
to a C library that calls the C getenv() function would see any change
in the environment.


More information about the Kepler-dev mailing list