[英]set System.getenv in Linux
Im building some application, where i would like to get some variable directly from linux. 我正在构建一些应用程序,我想直接从linux获取一些变量。
I know, that the command to get the variable is System.getenv(), but i don't exackly know where i should set variable in linux. 我知道,获取变量的命令是System.getenv(),但是我并不十分清楚我应该在linux中设置变量的位置。
I'm using Centos, and my tomcat is set in /usr/share/tomcat6 我正在使用Centos,并且我的tomcat设置在/ usr / share / tomcat6中
I was thinking, that maybe i should write it in /etc/profile file, but it doesn't works, and additionally i think that i should past the variable in user folder. 我当时在想,也许我应该将它写在/ etc / profile文件中,但是它不起作用,另外,我认为我应该将变量放在用户文件夹中。 User for Tomcat is tomcat, and his folder is /usr/share/tomcat6.
Tomcat的用户是tomcat,他的文件夹是/ usr / share / tomcat6。
Should i create there file profile
and add something like this? 我应该在此处创建文件
profile
并添加类似内容吗? : :
MY_VARIABLE=value
export MY_VARIABLE
Please help 请帮忙
From Terminal: 从终端:
gedit ~/.bashrc
~ here refers to /home/USER directory. 〜这里是指/ home / USER目录。
Edit the file: 编辑文件:
MY_VARIABLE=value
export MY_VARIABLE
confirm changes: 确认更改:
echo $MY_VARIABLE
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.