Apache Ant 1.8 on CentOS

情到浓时终转凉″ 提交于 2019-12-07 12:06:50

问题


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/


回答1:


Here are the steps required to get ant 1.8 installed on CentOS:

  1. Download http://archive.apache.org/dist/ant/binaries/apache-ant-1.8.4-bin.tar.gz
  2. Copy the tarball to your CentOS home folder (if it's not already there)
  3. tar xvzf apache-ant-1.8.4-bin.tar.gz
  4. sudo mv apache-ant-1.8.4 /opt/ant
  5. Set ANT_HOME=/opt/ant
  6. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!