My O.S. version is Ubuntu 14.04 LTS.

My Apache ant version is 1.9.3.

ant -version
Apache Ant(TM) version 1.9.3 compiled on April 8 2014

I want to update my Apache ant 1.9.4.(onwards)

Please help me, because when I'm using sudo apt-get install ant to update my ant.

But after this sudo command ant it showing following messages.

ant is already the newest version.

The following packages were automatically installed and are no longer required:

aspectj eclipse-platform-data eclipse-rcp fastjar jarwrapper junit4 libasm3-java libaspectj-java libbonoboui2-0 libbonoboui2-common
libcommons-beanutils-java libcommons-cli-java libcommons-codec-java
libcommons-collections3-java libcommons-compress-java libcommons-dbcp-java libcommons-digester-java libcommons-httpclient-java libcommons-lang-java libcommons-pool-java libdb-java libdb-je-java libdb5.3-java libdb5.3-java-jni libeasymock-java libecj-java libequinox-osgi-java
libfelix-bundlerepository-java libfelix-gogo-command-java
libfelix-gogo-runtime-java libfelix-gogo-shell-java libfelix-osgi-obr-java libfelix-shell-java libfelix-utils-java libgeronimo-jpa-2.0-spec-java libgeronimo-jta-1.1-spec-java libgeronimo-osgi-support-java libglade2-0 libgnomecanvas2-0 libgnomecanvas2-common libgnomeui-0 libgnomeui-common
libhamcrest-java libicu4j-4.4-java libicu4j-java libjetty8-java
libjline-java libjtidy-java libkxml2-java liblucene2-java
libosgi-compendium-java libosgi-core-java libosgi-foundation-ee-java
libservlet2.5-java libswt-cairo-gtk-3-jni libswt-glx-gtk-3-jni
libswt-gnome-gtk-3-jni libswt-gtk-3-java libswt-gtk-3-jni
libswt-webkit-gtk-3-jni libtomcat7-java libxz-java linux-headers-3.13.0-32 linux-headers-3.13.0-32-generic linux-image-3.13.0-32-generic linux-image-extra-3.13.0-32-generic linux-signed-image-3.13.0-32-generic sat4j Use 'apt-get autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.

  • Is there a particular reason why you want to upgrade ? – hg8 Sep 15 '15 at 8:50

Open up a Terminal with (Ctrl + t)

Remove the installed Ant either by remove or purge:

$ sudo apt-get purge ant

The output should be something like

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  ant* ant-optional*
0 upgraded, 0 newly installed, 2 to remove and 13 not upgraded.
After this operation, 3,057 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 310491 files and directories currently installed.)
Removing ant-optional (1.9.3-2build1) ...
Removing ant (1.9.3-2build1) ...
dpkg: warning: while removing ant, directory '/usr/share/ant/lib' not empty so not removed
Processing triggers for man-db ( ...

(I have a jar file in '/usr/share/ant/lib' which I need so I didn't clean that up.)

Download, verify signature, unpack and put the Apache Ant to for example /opt/ (According to their website it is suggested to use the latest version, but we specifically need 1.9.4, right? :-))

~$ cd Downloads
~/Downloads$ wget https://archive.apache.org/dist/ant/binaries/apache-ant-1.9.4-bin.tar.gz
~/Downloads$ wget https://www.apache.org/dist/ant/KEYS
~/Downloads$ wget https://archive.apache.org/dist/ant/binaries/apache-ant-1.9.4-bin.tar.gz.asc

~/Downloads$ gpg --import KEYS
~/Downloads$ gpg --verify apache-ant-1.9.4-bin.tar.gz.asc apache-ant-1.9.4-bin.tar.gz
~/Downloads$ gpg --fingerprint 82A7FBCD

~/Downloads$ tar -xvzf apache-ant-1.9.4-bin.tar.gz
~/Downloads$ sudo mv apache-ant-1.9.4 /opt/

More information about Apache Signature Verifying:


Create a symlink to your bin folder so your programs can call it

$ sudo ln -s /opt/apache-ant-1.9.4/bin/ant /usr/bin/ant

Usually your programs will need the ANT_HOME and ANT_OPTS environment variables:

export ANT_HOME="/opt/apache-ant-1.9.4"
export ANT_OPTS="-Xmx1024m"

To make it permanent put the above lines to ~/.bashrc. Here are the commands to do this: Either use an editor to edit .bashrc or from command line, just use the below commands.

Create a backup of .bashrc, before doing anything with it.

$ cp ~/.bashrc ~/.bashrc-backup

$ echo "" >> ~/.bashrc
$ echo "### ANT-SETUP by $USER" >> ~/.bashrc
$ echo "export ANT_HOME=\"/opt/apache-ant-1.9.4\"" >> ~/.bashrc
$ echo "export ANT_OPTS=\"-Xmx1024m\"" >> ~/.bashrc

Verify that the changes are correct

$ diff ~/.bashrc ~/.bashrc-backup

The output should be something like:

< ### ANT-SETUP by ${your_username}
< export ANT_HOME="/opt/apache-ant-1.9.4"
< export ANT_OPTS="-Xmx1024m"

Restart the Terminal or source the .bashrc

$ source ~/.bashrc

Verify the installation:

$ ant -diagnostics
|improve this answer|||||
  • 1
    Perfect answer for those still on Trusty, but a slight update to current times: XX:MaxPermSize is not supported from Java 8 onwards, so leave it out. Also the archives should be verified before being used, i.e. get the keys: wget https://www.apache.org/dist/ant/KEYS, also get the signature wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.9.4-bin.tar.gz.asc, import with gpg --import KEYS and verify with gpg --verify apache-ant-1.9.4-bin.tar.gz.asc. Update the version numbers to whatever you like. 1.9.9 for example. – kap Jan 29 '18 at 10:31
  • Thank you @kap for taking the time to respond, I updated the answer accordingly. – tnagy.adam Mar 15 '18 at 14:10

If there is no particular reason to upgrade to a newer version I would not upgrade.

Besides upgrading to 15.04 (that one has 1.9.4) ...

You could download all the DEB files from the packages page for Ant but I see a snag there: it requires you to also upgrade JRE and that is a lot of work.

Or you need to find 1.9.4 from outside of Ubuntu if you want a version your current release (ie. 14.04) does not provide yet. There is a warning on their website where you can find 1.9.6: "Older releases of Ant can be found here. We highly recommend to not use those releases but upgrade to Ant's latest release. Older versions can be found here".

The "tar.gz" at the link holds a "install" document that points to the online manual and it has a very large part on how to install it and how to make custom configuration settings work.

If you do need to upgrade do pick 1.9.6 over 1.9.4.

|improve this answer|||||
  • @JalT good on you :) please do not forget to upvote and if applicable accept an answer that suits you best (not does not have to be mine ;-) ) Otherwise the system will keep bumping this question to the frontpage – Rinzwind Sep 24 '15 at 10:24

Ant 1.9.3 is the latest stable and supported version for Ubuntu 14.04.
Ant 1.9.4 is the package aimed at Ubuntu 15.04 and is currently only present in the Vivid Vervet repository.

Refer here for more information.

Moreover if you want to upgrade your Ant package in the future you will need to run :

sudo apt-get upgrade

Because sudo apt-get install <package> is only for installing a package, not for update it ;)

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.