java CentOS 上的 Apache Ant 1.8

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15698809/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 20:33:16  来源:igfitidea点击:

Apache Ant 1.8 on CentOS

javaantbuildcentosenv

提问by BullShark

I am trying to get apache ant 1.8 to work under CentOS. First, I had this error.

我正在尝试让 apache ant 1.8 在 CentOS 下工作。首先,我有这个错误。

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

Ant:线程“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:

它不是 CentOS,但我确实验证了除 JAVA_HOME 之外的路径存在,因此我根据此站点进行设置:

https://serverfault.com/questions/50883/what-is-the-value-of-java-home-for-centos

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:

如果你想尝试,你可以在 CentOS 上克隆他:

https://github.com/BullShark/JRobo

https://github.com/BullShark/JRobo

For Apache Ant 1.8 on CentOS:

对于 CentOS 上的 Apache Ant 1.8:

http://www.jpackage.org/browser/rpm.php?jppversion=6.0&id=11867

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/

https://ant.apache.org/bindownload.cgi?Preferred=ftp://apache.mirrors.pair.com/

回答by Kevin Driedger

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

以下是在 CentOS 上安装 ant 1.8 所需的步骤:

  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
  1. 下载http://archive.apache.org/dist/ant/binaries/apache-ant-1.8.4-bin.tar.gz
  2. 将 tarball 复制到您的 CentOS 主文件夹(如果它还没有)
  3. tar xvzf apache-ant-1.8.4-bin.tar.gz
  4. sudo mv apache-ant-1.8.4 /opt/ant
  5. 设置 ANT_HOME=/opt/ant
  6. 添加“ export ANT_HOME=/opt/ant/etc/profile

To verify that it worked, run:

要验证它是否有效,请运行:

ant -version