File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Linux / UNIX and the fly likes installing ant on centos Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "installing ant on centos" Watch "installing ant on centos" New topic

installing ant on centos

Jeroen Nouws

Joined: Jul 14, 2011
Posts: 17
Hey i'm trying to get ant installed on my centos box
preinstalled came a ant 1.7 but now i want to upgrade it to 1.8 (just for the heck of it)
i downloaded the tarball and unpacked it in /usr/local/ant and set my system variables in the /root/.bash_profiles
however if i run ant -version i still get ant 1.7 how can i make sure my default is 1.8?

Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11776

I take it you are logging in to your CentOS box as root, and running Java that way. This will cause you problems down the line, however it is not directly related to your problem so I won't comment further at this time.

What changes did you make to your .bash_profile? Note - singular, not plural. If you changed .bash_profiles then you modified the wrong file.

Did you re-source the .bash_profile file after modifying it? That is:

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Peter Johnson

Joined: May 14, 2008
Posts: 5852

Please tell us exactly what you set the system variables to, especially the PATH. Also, what do you get when you run:

which ant

If the result is /usr/bin/ant, you need to also do:

ls -al /usr/bin/ant

because it could be a softlink to the old 1.7 version.

Fun and games like this are why I never install any Java stuff using the packages that come with a disto...

JBoss In Action
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

I'm in agreement with Peter. I am a VERY big fan of the RPM package manager, but the one place where I avoid it is for Java stuff (except for my own code). One of the reasons I do that is because the OS provider generally doesn't give you the most up-to-date version of the software. An extreme case, in fact, was Sun's Solaris 10, which came with Tomcat4 as the packaged server even though Tomcat4 had already passed End of Life (ironic, much?).

To run your own version of Ant, however, you can do this:

1. Download the desired Ant archive.

2. Explode it (I usually end up with /usr/local/apache-ant-x.y.z).

3. Set your environment variable for ANT_HOME to be the directory named in Step 2.

4. Add $ANT_HOME/bin to your PATH at the HEAD of the path (so that it will override the other Ant version). Also, of course, you need to have $JAVA_HOME/bin setup for whichever JVM Ant should be running under.

Items 3 and 4 can be done in build script or in your profile, whichever is most convenient.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: installing ant on centos
It's not a secret anymore!