Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set ANT_HOME on Ubuntu Desktop 12.04?

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.

  • Which file do I use?
  • How do I actually set it so that it meets my requirements above?

Thanks in advance for any help or pointers here!

like image 545
IAmYourFaja Avatar asked Sep 01 '12 04:09

IAmYourFaja


People also ask

How do you set an ant home window?

Choose Start -> Control Panel, and double-click the System icon. Click the Advanced tab, and then click the Environment Variables button. Under System Variables, select New to create the ANT_HOME environment variable.

Where is my ant path Linux?

In your home folder, open the . bash_profile file in the root directory. To test the setting, type ant at a command prompt and press Return. If a Build not found error message appears, you have correctly installed Ant.

How do you set up an ant?

Installing Apache AntEnsure that the JAVA_HOME environment variable is set to the folder, where your JDK is installed. Unzip the zip file to a convenient location c:\folder by using Winzip, winRAR, 7-zip or similar tools. Create a new environment variable called ANT_HOME that points to the Ant installation folder.

How do you set up an ant home on a Mac?

Environment VariableSet the command ant as the environment variable, so that you can “ant” build your project everywhere. Exports $ANT_HOME/bin , save and restart terminal. Test it again, now, you can access the ant command everywhere. Done.


1 Answers

For global settings, system-wide environment variables

  • Use /etc/environment
  • don't use /etc/profile, or /etc/bash.bashrc

From this page :

/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.

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 .

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

For local or per-user settings

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 - 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 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 - "... may be the easiest place to set variables".

like image 125
Mehdi Avatar answered Oct 06 '22 22:10

Mehdi