Apache Ant 1.8 on CentOS
Here are the steps required to get ant 1.8 installed on CentOS:
- Download http://archive.apache.org/dist/ant/binaries/apache-ant-1.8.4-bin.tar.gz
- Copy the tarball to your CentOS home folder (if it's not already there)
tar xvzf apache-ant-1.8.4-bin.tar.gz
sudo mv apache-ant-1.8.4 /opt/ant
- Set ANT_HOME=/opt/ant
- Add ‘
export ANT_HOME=/opt/ant
’ to/etc/profile
To verify that it worked, run:
ant -version
BullShark
Updated on June 04, 2022Comments
-
BullShark almost 2 years
I am trying to get apache ant 1.8 to work under CentOS. First, I had this error.
Error: Could not find or load main class org.apache.tools.ant.launch.Launcher
Then I set the following variables according to this link:
Ant: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher
It's not CentOS, but I did verify the paths exist except JAVA_HOME, so I set it according to this site:
https://serverfault.com/questions/50883/what-is-the-value-of-java-home-for-centos
Now I am getting the same error I did the first time. It does not matter which ant rule I use, I still get the same error.
[alpha:~] [bullshark]% export JAVA_HOME=/usr/lib/jvm/jre-1.7.0-openjdk.x86_64/ [alpha:~] [bullshark]% export ANT_HOME=/usr/share/ant/ [alpha:~] [bullshark]% export PATH=$PATH:$ANT_HOME/bin [alpha:~] [bullshark]% cd JRobo [alpha:JRobo] on master [bullshark]% ant clean-and-fat-jar Picked up _JAVA_OPTIONS: -Xmx64m Error: Could not find or load main class org.apache.tools.ant.launch.Launcher [alpha:JRobo] on master [bullshark]% cat /etc/redhat-release CentOS release 6.3 (Final) [alpha:JRobo] on master [bullshark]%
You can clone him on CentOS if you want to try:
https://github.com/BullShark/JRobo
For Apache Ant 1.8 on CentOS:
http://www.jpackage.org/browser/rpm.php?jppversion=6.0&id=11867
For a package or manually:
https://ant.apache.org/bindownload.cgi?Preferred=ftp://apache.mirrors.pair.com/
-
asgs about 11 yearswhat does "which ant" return?
-
Mark O'Connor about 11 yearsI had problems getting ANT to work properly using the package manager. Different jars have been split out into different RPM packages... I found it a lot simpler to just download the ANT binary release and install it under the "/opt" directory.
-
BullShark about 11 years% which ant /usr/bin/ant
-
BullShark about 11 yearsI switched from CentOS 6.3 to Fedora 17, and now I have all the latest java packages. I'm running apache tomcat 1.7 and ant 1.8 from rpm packages without problems now.
-
-
Nic Cottrell over 10 yearsThanks - worked great. Is
/etc/profile
really the place to put the export? The comments in that file suggest that/etc/profile.d/custom.sh
might be better (easier for package upgrades) -
likern about 9 yearsDid you forget to add
export PATH="$ANT_HOME/bin:$PATH"
? Because otherwise you won't be able to run ant without declaring absolute path toant
binary. -
gerardw over 8 yearsAdding an "ant.sh" to /etc/profile.d works on CentOS release 6.6 (Final) It's not necessary to add to your path if there is an existing version of ant already on it (at least 1.7.1 in my case) because the script uses ANT_HOME to find the jars to run.