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.