简体   繁体   English

Java 系统属性和环境变量

[英]Java system properties and environment variables

What's the difference between system properties System.getProperties() and environment variables System.getenv() in a JVM? JVM 中的系统属性System.getProperties()和环境变量System.getenv()有什么区别?

I think the difference between the two boils down to access.我认为两者之间的区别归结为访问。 Environment variables are accessible by any process and Java system properties are only accessible by the process they are added to.任何进程都可以访问环境变量,并且 Java 系统属性只能由添加它们的进程访问。

Also as Bohemian stated, env variables are set in the OS (however they 'can' be set through Java) and system properties are passed as command line options or set via setProperty() .同样正如 Bohemian 所说,环境变量是在操作系统中设置的(但是它们“可以”通过 Java 设置),系统属性作为命令行选项传递或通过setProperty()设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM