2

I'm using Ubuntu 14.04 (on a VirtualBox VM) and installed Apache Ant via aptitude:

$ aptitude install ant

The binary is stored in /usr/bin/:

$ which ant
/usr/bin/ant

Now I want to set ANT_HOME and also add it to my PATH environment variable. On Windows it would be easy to find the correct folder -- ANT_HOME is the folder, where the installation is stored and looks like C:\Program Files\Apache Ant (or simply the parent directory of the folder with the Ant binaries).

How to find out the correct path for ANT_HOME in a Linux system (e.g. Ubuntu Server)?


UPDATE

The documentation on the Oracle website says:

Add the following lines to the file, substituting the directory where you installed Ant:

ANT_HOME=/apache-install-dir/apache-ant-version

How to find out the path to the apache-install-dir?

automatix
  • 682
  • 3
  • 7
  • 19
  • use export ANT_HOME='/usr/bin', or use this [link](https://docs.oracle.com/cd/E19316-01/820-7054/gickh/index.html) provided by oracle – Alin Andrei Apr 11 '16 at 06:48
  • @AlinAndrei Thanks for your comment, but what I'd actually like to know is not how to set the environment variable, but _how_ to know / _how_ to find out, which path for `ANT_HOME` is correct on a Linux machine. So did you mean, the `ANT_HOME` is always the folder with executables, where the Ant executable is? – automatix May 30 '16 at 07:44

1 Answers1

6

On CentOS/Ubuntu ANT_HOME should be /usr/share/ant/. You can check /usr/share/ant/bin/ant, it's just a bash script

# load system-wide ant configuration (ONLY if ANT_HOME has NOT been set)
  if [ -z "$ANT_HOME" -o "$ANT_HOME" = "/usr/share/ant" ]; then
      if [ -f "/etc/ant.conf" ] ; then
          . /etc/ant.conf
      fi
  fi

So if you didn't specify explicitly ANT_HOME, /usr/share/ant will be used by default.

ALex_hha
  • 7,025
  • 1
  • 23
  • 39