Eclipse 中的环境变量 [英] Environment variables in Eclipse
问题描述
我能够从命令提示符运行示例 hadoop 程序,并尝试从 Eclipse 运行相同的程序,以便我可以调试它并更好地理解它.
I am able to run a sample hadoop program from the command prompt and am trying to run the same program from Eclipse, so that I can debug it and understand it better.
对于命令行程序,在.bashrc
中设置了一些环境变量,并且和System.getenv().get("HADOOP_MAPRED_HOME")
一样被读取> 在 hadoop 程序中.但是,当我使用 System.getenv().get("HADOOP_MAPRED_HOME")
运行 java 程序时,从 Eclipse 中我得到了空值.
For the command line program, some environment variables are set in the .bashrc
and the same are being read as System.getenv().get("HADOOP_MAPRED_HOME")
in the hadoop program. But, when I am running a java program with System.getenv().get("HADOOP_MAPRED_HOME")
, from Eclipse I am getting null.
我尝试在 Eclipse 的运行时配置中将 -DHADOOP_MAPRED_HOME=test
传递给 VM 参数,但在独立程序中仍然为空.如何使环境变量在 Eclipse 中可见?当我在 Eclipse 中遍历 System.getenv()
时,我看到很多变量,如 DISPLAY
、USER
、HOME
> 和其他.他们在哪里设置?我使用的是 Ubuntu 11.04.
I tried passing -DHADOOP_MAPRED_HOME=test
to VM parameters in the runtime configurations from Eclipse, but still getting null in the standalone program. How to make the environment variables visible within Eclipse? When I iterate through System.getenv()
in Eclipse, I see lot of variables like DISPLAY
, USER
, HOME
and others. Where are they set? I am using Ubuntu 11.04.
推荐答案
.bashrc 文件用于设置交互式登录 shell 使用的变量.如果您希望在 Eclipse 中使用这些环境变量,您需要将它们放在/etc/environment 中.
The .bashrc file is used for setting variables used by interactive login shells. If you want those environment variables available in Eclipse you need to put them in /etc/environment.
这篇关于Eclipse 中的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!