Linux – How to find out the correct path for ANT_HOME in Linux

antenvironment-variableslinuxubuntu-14.04

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?

Best Answer

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.

Related Topic