In this article we’ll show how to install Ant on Linux. Ant is one of the most popular (though certainly not the only) build tool for Java programming, and once your Java development project reaches a certain complexity it’s bound to need Ant. Most distributions have some version of Ant included, but it’s often outdated and set to use some distribution-specific version of Java that’s not 100% ok.
So instead we’ll show how to install Ant from scratch, which is really quite easy.
This article requires basic Linux command line skills. Additionally we’ll assume that you have Java installed somehow and are happy with that version. If you don’t know which version you have you can try it out with:
Download the current release of Ant from the official site in .tar.gz format. Here we’ll use /usr/java as the installation location, but you can put it in any directory where your user has write permissions.
mv apache-ant*.tar.gz /usr/java cd /usr/java tar xzf apache-ant*.tar.gz rm apache-ant*.tar.gz apache-ant-*/bin/ant -version
If this doesn’t produce errors and the last command above shows the version of Ant (e.g. “Apache Ant(TM) version 1.8.4 compiled on May 22 2012”) you’re set.
If the ant command cannot find Java you should run:
Note that we didn’t add Ant to the shell path yet. You can do so if you want, but in my opinion it’s better to explicitly run
because that way it will be clearer which version of Ant you are using.