How can my Java code read OS environment variables? [duplicate]

流过昼夜 提交于 2019-12-30 06:22:30

问题


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 -D variables supplied directly for the JVM.

How can my Java code read OS variables?


回答1:


Try System.getenv(String name)



来源:https://stackoverflow.com/questions/461018/how-can-my-java-code-read-os-environment-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!