CentOS how to update Ant Version to 1.8.x and higher?

27,633

Solution 1

Awk's answer may probably work, but for some reason, it's not working for me. Then i found this (a bit different) answer by Googling.

  1. Download “bin” Release from http://ant.apache.org/bindownload.cgi
  2. Extract & copy/move the whole folder (apache-ant-1.9xxxxx) into /opt/. So there will be /opt/apache-ant-1.9xxxxxx/
  3. Make a Symlink: ln -s /opt/apache-ant-1.9.xxxxx /opt/ant
  4. Make another Symlink: ln -s /opt/ant/bin/ant /usr/bin/ant
  5. Set ANT_HOME into the Environment vi /etc/environment and add this line: ANT_HOME=/opt/ant (without trailing slash)
  6. Re-login to initiate the Environment.

That one perfectly works for me.

Solution 2

The answer from 夏期劇場 works, but it has few extra steps that aren't strictly necessary. The following configuration worked for me compiling Solr.

Download and extract ant into /opt/ant

$ sudo -i
# cd /opt
# wget http://apache.parentingamerica.com//ant/binaries/apache-ant-1.9.6-bin.tar.bz2
# tar xjf apache-ant-1.9.6-bin.tar.bz2
# mv apache-ant-1.9.6 ant

Remove any existing ant packages

# yum remove -y `rpm -qa | grep '^ant-'`

Create symlink to ant executable

# ln -s /opt/ant/bin/ant /usr/local/bin/ant

If you want ant to be available for root user, then create symlink to ant executable from /usr/local/sbin

# ln -s /opt/ant/bin/ant /usr/local/sbin/ant

Logout out of the system and log back in, command ant should be available for you to use.

Share:
27,633

Related videos on Youtube

夏期劇場
Author by

夏期劇場

Updated on September 18, 2022

Comments

  • 夏期劇場
    夏期劇場 over 1 year

    I'm using CentOS 6.5 and installed Ant by using:

    yum install ant
    

    It came with Ant version 1.7.1, but I need the latest -- version 1.8.0.

    • How to properly get the latest Ant version 1.8.x (or higher) from YUM or any way please?
  • 夏期劇場
    夏期劇場 about 10 years
    Move to /opt/bin or /opt/ant, please? (I do not find opt/bin)
  • Akshay Hegde
    Akshay Hegde about 10 years
    Sorry it was /opt/ant, actually you can keep binary in any location, but export ANT_HOME=your/binary/path in /etc/profile or .bashrc is important.
  • Lambart
    Lambart over 4 years
    Works fine for me, but I didn't need to edit /etc/environment.
  • Lambart
    Lambart over 4 years
    This works fine, but don't copy the exact commands unless you really want v.1.9.6! Go to ant.apache.org/bindownload.cgi to download the version you're looking for.