I wonder which of the following is a preferred approach?
We can set things up as APP_HOME=/path/to/file
(export
in .profile
or som
The Javadoc for System.getenv(String)
addresses this question directly, saying:
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
).
(emphasis mine).