如何在Ubuntu Desktop 12.04上设置ANT_HOME? [英] How to set ANT_HOME on Ubuntu Desktop 12.04?

查看:40
本文介绍了如何在Ubuntu Desktop 12.04上设置ANT_HOME?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ubuntu似乎使用了〜/.bashrc 〜/.bash_profile 〜/.pam_profile /etc/环境/etc/profile 的方式非常相似.我希望能够向其中之一添加配置(以适当的配置为准),以将 ANT_HOME 设置为我的Ant安装目录的根目录的绝对路径(可能是>/opt/apache/ant/1.8.4/apache-ant-1.8.4/).像任何普通的env var一样,此变量"需要兑现",在这里我可以打开终端并随时 echo .如果我可以通过这样一种方式设置Java,以便Java在运行时从 System.getProperty(")调用中读取它,那也很好.

It looks like Ubuntu uses ~/.bashrc, ~/.bash_profile, ~/.pam_profile, /etc/environment, and /etc/profile in very similar ways. I'd like to be able to add a configuration to one of these (which ever is the appropriate one) to set ANT_HOME to be the absolute path to my Ant installation's root directory (happens to be /opt/apache/ant/1.8.4/apache-ant-1.8.4/). This variable needs to be "honored" as is any normal env var, where I can open up a terminal and echo it at any time. It would also be nice if I could set this in such a way for Java to read it in at runtime from a System.getProperty("") call.

  • 我使用哪个文件?
  • 我如何实际设置它以满足我的上述要求?

在此先感谢您的帮助或指点!

Thanks in advance for any help or pointers here!

推荐答案

对于全局设置,系统范围的环境变量

  • 使用/etc/environment
  • 请勿使用/etc/profile /etc/bash.bashrc

来自页面:

/etc/environment [...]是专门用于系统范围环境变量设置.它是不是脚本文件,而是由赋值表达式,每个线.具体来说,此文件存储系统范围的语言环境和路径设置.

/etc/environment [...] is specifically meant for system-wide environment variable settings. It is not a script file, but rather consists of assignment expressions, one per line. Specifically, this file stores the system-wide locale and path settings.

使用/etc/profile 是一种非常Unix-y的方式,但是在Ubuntu下它的功能大大降低了.它仅指向/etc/bash.bashrc 并从/etc/profile.d 收集条目.

Using /etc/profile is a very Unix-y way to go, but its functionality is greatly reduced under Ubuntu. It exists only to point to /etc/bash.bashrc and to collect entries from /etc/profile.d .

在我的系统上,profile.d中唯一有趣的条目是/etc/profile.d/bash_completion.sh .

On my system, the only interesting entry entry in profile.d is /etc/profile.d/bash_completion.sh .

用于本地或每个用户设置

Ubuntu页面的先前版本建议〜/.pam_environment ,但是该页面当前建议,如果这不起作用,则应使用

A previous version of the Ubuntu page recommended ~/.pam_environment , but the page currently suggests that if that doesn't work, you should use

〜/.profile -这可能是放置环境的最佳文件变量赋值,因为它得到由...自动执行启动期间的DisplayManager处理桌面会话以及从一个登录名时的登录shell文本控制台.

~/.profile - This is probably the best file for placing environment variable assignments in, since it gets executed automatically by the DisplayManager during the startup process desktop session as well as by the login shell when one logs-in from the textual console.

  • 〜/.bash_profile 〜./bash_login -如果其中之一存在,当bash为作为登录shell开始.Bash倾向于〜/.bash_profile 而不是〜/.bash_login .[...]默认情况下,这些文件不会影响图形会话."

  • ~/.bash_profile or ~./bash_login - If one of these exists, bash executes it instead of "~/.profile" when bash is started as a login shell. Bash will prefer ~/.bash_profile to ~/.bash_login. [...] These files won't influence a graphical session by default."

    〜/.bashrc -"...可能是设置变量的最简单位置".

    ~/.bashrc - "... may be the easiest place to set variables".

    这篇关于如何在Ubuntu Desktop 12.04上设置ANT_HOME?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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