Eclipse中的环境变量 [英] Environment variables in Eclipse

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

问题描述

我可以从命令提示符运行一个样例hadoop程序,并尝试从Eclipse运行相同的程序,以便我可以调试它,并更好地理解。



对于命令行程序,在 .bashrc 中设置了一些环境变量,并且正在读取 System.getenv()。 geto(HADOOP_MAPRED_HOME)在hadoop程序中。但是,当我使用 System.getenv()。get(HADOOP_MAPRED_HOME)运行一个Java程序时,从Eclipse中我将变为null。



我尝试从Eclipse中运行配置中的VM参数传递 -DHADOOP_MAPRED_HOME = test ,但在独立程序中仍然为空。如何使环境变量在Eclipse中可见?当我在Eclipse中遍历 System.getenv()时,我看到很多变量,如 DISPLAY USER HOME 等。他们在哪里设置?我正在使用Ubuntu 11.04。

解决方案

.bashrc文件用于设置交互式登录shell使用的变量。如果您希望Eclipse中提供这些环境变量,则需要将它们放在/ etc / environment中。


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.

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.

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.

解决方案

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屋!

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