Java-设置环境变量 [英] Java - set environment variable
本文介绍了Java-设置环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一段看起来像这样的代码:
I have a piece of code that looks something like this:
if(System.getenv(ZOOKEEPER_HOSTS_SYS) == null){
//here I want to do something like:
//System.setenv(ZOOKEEPER_HOSTS_SYS,"");
}
有什么想法如何像评论中那样设置environment variable
?
Any idea how to set the environment variable
like in the comment?
我不想启动新进程或类似的东西,我想为当前进程设置它.
I do not want to launch a new process or anything like that, I want to set it for the current process.
谢谢. 问候
塞尔维亚人
推荐答案
您可以使用System.getProperty和System.setProperty
You can use System.getProperty and System.setProperty
这篇关于Java-设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文