Java System.getEnv() [英] Java System.getEnv()

查看:276
本文介绍了Java System.getEnv()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Mac OSX和Linux CentOS中,我使用.bashrc& .bash_profile.我什至重启了笔记本电脑(mac)和服务器(linux).

In mac OSX and in Linux CentOS, I insert a new system environment variable (i.e. "MYAPP") using .bashrc & .bash_profile. I even restarted my laptop (mac) and my server (linux).

当我使用命令行"env"时,该环境变量显示为正确的值.但是无论如何,每次我尝试在Mac或Linux上的Java应用程序(台式机应用程序或Web应用程序或EJB或servlet其他任何Java应用程序)中获取它时,都不会检索该环境变量("MYAPP").

When I use the command line "env", that environment variable showed with the correct value. But somehow every time I try to get it in a Java app (desktop app or web app or EJB or servlet any other java app) in either mac or linux, that environment variable ("MYAPP") is not retrieved.

我试图遍历Java可以检索的整个环境变量,结果发现它检索了除"MYAPP"以外的所有环境变量.这很奇怪.

I tried to iterate through the entire environment variables that Java can retrieve and it turns out that it retrieves every environment variables other than "MYAPP". This is very odd.

有人知道如何解决这个问题吗?

Anyone know how to solve this?

推荐答案

定义并导出环境变量之后.从同一终端启动您的IDE.

After having defined and exported the environment variable. Launch your IDE from the same Terminal.

这篇关于Java System.getEnv()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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