When to use environment variables vs. system properties?

后端 未结 4 1414
眼角桃花
眼角桃花 2021-02-05 23:56

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

4条回答
  •  北海茫月
    2021-02-06 00:41

    Can't comment yet at the moment, so I will add a couple of points as an answer.

    I agree with the javadoc's saying "It is best to use system properties where possible.", also in my own words previous to seeing this page here that the Java system variables are encapsulated inside the JVM. They are not visible to other processes on the host, and thus less coupled with the host system.

    In addition, there are multiple interfaces to set the global environment variables, and so it could be a bit tricky to track all the values being used over time.

提交回复
热议问题