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

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

问题描述

看起来Ubuntu使用了~/.bashrc~/.bash_profile~/.pam_profile/etc/environment/etc/profile 以非常相似的方式.我希望能够将配置添加到其中一个(以适当的方式为准)以将 ANT_HOME 设置为我的 Ant 安装根目录的绝对路径(恰好是 /opt/apache/ant/1.8.4/apache-ant-1.8.4/).这个变量需要像任何普通的 env var 一样被尊重",我可以随时打开一个终端并 echo 它.如果我能以这样一种方式设置它,让 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处理桌面会话以及通过登录时的登录外壳文本控制台.

~/.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 为作为登录外壳启动.与 ~/.bash_login 相比,Bash 更喜欢 ~/.bash_profile.[...] 默认情况下,这些文件不会影响图形会话."

  • ~/.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天全站免登陆