我的 Java 代码如何读取操作系统环境变量?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/461018/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can my Java code read OS environment variables?
提问by Amir Arad
This may be a very simple problem, but I couldn't find an answer googleing and I'm in a rush - so I'd appreciate fast code examples.
这可能是一个非常简单的问题,但我在谷歌上找不到答案,而且我很匆忙 - 所以我很欣赏快速的代码示例。
I have an environment variable on the OS I would like to read using Java code. I've tried System.getProperty, but that only seems to work for the -Dvariables supplied directly for the JVM.
我想使用 Java 代码读取操作系统上的环境变量。我试过了System.getProperty,但这似乎只适用于-D直接为 JVM 提供的变量。
How can my Java code read OS variables?
我的 Java 代码如何读取操作系统变量?

