在java中获取环境变量的值? [英] getting environment variable's value in java?

查看:157
本文介绍了在java中获取环境变量的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Windows中通过名称"sample"设置了环境变量.我可以使用以下代码获取此环境变量的值吗?

I have set an environment variable in windows by name "sample". Can I get this environment variable's value using below code?

System.getProperty("sample");

在UAT环境中,我有LINUX OS.我可以在LINUX OS中设置相同的环境变量,然后使用System.getProperty("sample")检索相同的变量吗?

in UAT environment I have LINUX OS. Can I set the same environment variable in LINUX OS and retrieve the same using System.getProperty("sample")?

我的意思是System.getProperty("sample");是否检索与操作系统无关的内容?

I mean does System.getProperty("sample"); retrieves irrespective of the operating system?

此外,我想在JSP中获取环境变量的值.我知道不建议将逻辑保留在jsp中,但仍然需要使用它.我可以在jsp中使用System.getProperty("sample");吗?请帮助我.

Also, I would like to get the environment variable's value in JSP.I know it is not recommended to keep logic in jsp but still, I need to use it. Can I use System.getProperty("sample"); in jsp? Please help me.

推荐答案

是的,这与操作系统无关,您可以在JSP中使用它.

yes this is irrespective of OS and you can use it in JSP.

这篇关于在java中获取环境变量的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆