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/
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
来源:https://stackoverflow.com/questions/15698809/apache-ant-1-8-on-centos