Java 如何安装 Apache Ant?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/697006/
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-08-11 18:27:37  来源:igfitidea点击:

How to install Apache Ant?

javaapacheant

提问by

I want to install SMSlib (http://smslib.org/) in installation instruction (http://code.google.com/p/smslib/wiki/Installation).

我想在安装说明 ( http://code.google.com/p/smslib/wiki/Installation) 中安装 SMSlib ( http://smslib.org/)。

In here I must install Apache Ant, but I didn't understand how to do that. I already download Apache Ant 1.7.1 , read manual (http://ant.apache.org/manual/index.html)

在这里,我必须安装 Apache Ant,但我不明白该怎么做。我已经下载了 Apache Ant 1.7.1,阅读手册(http://ant.apache.org/manual/index.html

In here I must have RPM version from jpackage.org right? I already go to http://www.jpackage.org/after that what must I do? I already try (http://mirrors.dotsrc.org/jpackage/1.7/generic/free/repodata/) and (http://www.jpackage.org/browser/browse.php?jppversion=1.7) but too many link. I don't know witch one must I download

在这里我必须有来自 jpackage.org 的 RPM 版本,对吗?我已经去了http://www.jpackage.org/之后我该怎么办?我已经尝试过(http://mirrors.dotsrc.org/jpackage/1.7/generic/free/repodata/)和(http://www.jpackage.org/browser/browse.php?jppversion=1.7)但是太多了关联。我不知道我必须下载一个女巫

回答by yottamoto

Sound's like you're using Linux. If so, the easiest way would be to use a package management frontend like Synaptic and install ant in there.

听起来就像您在使用 Linux。如果是这样,最简单的方法是使用像 Synaptic 这样的包管理前端并在其中安装 ant。

回答by Prabhu R

the installation of ant and smslib is pretty simple. All you need to do is extract it to some directory. Export the path in case of Linux or set the ANT_HOME\bin to the PATH variable to access it from any directory in the shell. ANT_HOME is the root directory where ant is installed.

ant 和 smslib 的安装非常简单。您需要做的就是将其解压缩到某个目录。在 Linux 的情况下导出路径或将 ANT_HOME\bin 设置为 PATH 变量以从 shell 中的任何目录访问它。ANT_HOME 是安装ant 的根目录。

For SMSLib Download the zip file and this linkshould guide you on a step by step basis

对于 SMSLib 下载 zip 文件,此链接应逐步指导您

回答by XZVASFD

If you're on Windows, you can use WinAnt, a Windows installer for Apache Ant that I made.

如果您使用的是 Windows,则可以使用WinAnt,这是我为 Apache Ant 制作的 Windows 安装程序。

回答by salman khalid

Its very simple just install Apache ant installer for windows give on [link][1]

它非常简单,只需在 [link][1] 上为 windows 安装 Apache ant 安装程序

[1]: http://code.google.com/p/winant/and all is set.No need to set Environment variables.It will automatically do every thing for you.

[1]:http: //code.google.com/p/winant/一切都设置好了。不需要设置环境变量。它会自动为你做每件事。

回答by spr

1) Download "apache-ant-1.8.4-bin.zip" from "http://ant.apache.org/bindownload.cgi"

1) 从“ http://ant.apache.org/bindownload.cgi”下载“apache-ant-1.8.4-bin.zip ”

2) Unzip it and copy "apache-ant-1.8.4" in "c:\Program Files"

2) 解压并将“apache-ant-1.8.4”复制到“c:\Program Files”

3) Right Click "My Computer" -> properties -> Advanced -> Environment variables -> Edit variable "PATH" and append value "C:\Program Files\Java\jdk 1.7.0_04\bin;C:\Program Files\apache-ant-1.8.4\bin" and Click "OK".

3)右键单击“我的电脑”-> 属性-> 高级-> 环境变量-> 编辑变量“PATH”并附加值“C:\Program Files\Java\jdk 1.7.0_04\bin;C:\Program Files\ apache-ant-1.8.4\bin”,然后单击“确定”。

4) open cmd and type "ant" for checking.

4)打开cmd并输入“ant”进行检查。

回答by Sandeep Gouda

Step 1:Download and install

第 1 步:下载并安装

Download Ant. Go to the Ant homepageand click to download the binary. Because we're talking about Windows, choose to download the ZIP file rather than any of the others. Scroll down to where it says “Current release of Ant” and click on the ZIP filename.

下载蚂蚁。进入Ant 主页,点击下载二进制文件。因为我们在谈论 Windows,所以选择下载 ZIP 文件而不是任何其他文件。向下滚动到“当前版本的 Ant”,然后单击 ZIP 文件名。

Once downloaded, unzip the file. You'll now need to choose a permanent home for Ant on the computer. c:\java\antis often used, but you can put it wherever you want.

下载后,解压文件。您现在需要在计算机上为 Ant 选择一个永久的家。c:\java\ant经常使用,但你可以把它放在任何你想要的地方。

Step 2:Set environment variables

第二步:设置环境变量

For Windows XP:To set environment variables on Windows XP, right click on My Computer and select Properties. Then go to the Advanced tab and click the Environment Variables button at the bottom.

对于 Windows XP:要在 Windows XP 上设置环境变量,请右键单击我的电脑并选择属性。然后转到“高级”选项卡并单击底部的“环境变量”按钮。

For Windows 7:To set environment variables on Windows 7, right click on Computer and select Properties. Click on Advanced System Settings and click the Environment Variables button at the bottom. The only environment variable that you absolutely need is JAVA_HOME, which tells Ant the location of your JRE.

对于 Windows 7:要在 Windows 7 上设置环境变量,请右键单击计算机并选择属性。单击高级系统设置,然后单击底部的环境变量按钮。您绝对需要的唯一环境变量是 JAVA_HOME,它告诉 Ant 您的 JRE 的位置。

If you've installed the JDK, this is likely

如果你已经安装了 JDK,这很可能

c:\Program Files\Java\jdk1.x.x\jre

on Windows XP and

在 Windows XP 和

c:\Program Files(x86)\Java\jdk1.x.x\jre

on Windows 7. You'll note that both have spaces in their paths, which causes a problem. You need to use the mangled name[3] instead of the complete name. So for Windows XP, use C:\Progra~1\Java\jdk1.x.x\jre and for Windows 7, use C:\Progra~2\Java\jdk1.6.0_26\jre if it's installed in the Program Files(x86) folder

在 Windows 7 上。您会注意到它们的路径中都有空格,这会导致问题。您需要使用损坏的名称 [3] 而不是完整名称。因此,对于 Windows XP,请使用 C:\Progra~1\Java\jdk1.xx\jre,对于 Windows 7,如果安装在 Program Files(x86) 中,请使用 C:\Progra~2\Java\jdk1.6.0_26\jre ) 文件夹

That alone is enough to get Ant to work, but for convenience, it's a good idea to add the Ant binary path to the PATH variable.

仅此一项就足以让 Ant 工作,但为了方便起见,将 Ant 二进制路径添加到 PATH 变量是个好主意。

This variable is a semicolon-delimited list of directories to search for executables. To be able to run ant in any directory, Windows needs to know both the location for the ant binary and for the java binary. You'll need to add both of these to the end of the PATH variable. For Windows XP, you'll likely add something like this:

此变量是以分号分隔的目录列表,用于搜索可执行文件。为了能够在任何目录中运行 ant,Windows 需要知道 ant 二进制文件和 java 二进制文件的位置。您需要将这两个添加到 PATH 变量的末尾。对于 Windows XP,您可能会添加如下内容:

;c:\java\ant\bin;C:\Progra~1\Java\jdk1.x.x\jre\bin

For Windows 7, it will look something like this:

对于 Windows 7,它看起来像这样:

;c:\java\ant\bin;C:\Progra~2\Java\jdk1.x.x\jre\bin

Done

完毕

Once you've done that and applied the changes, you'll need to open a new command prompt to see if the variables are set properly. You should be able to simply run ant and see something like this:

完成此操作并应用更改后,您需要打开一个新的命令提示符以查看变量设置是否正确。您应该能够简单地运行 ant 并看到如下内容:

Buildfile: build.xml does not exist!
Build failed

That means Ant is installed properly and is looking for a build.xml file.

这意味着 Ant 已正确安装并且正在寻找 build.xml 文件。

Source: http://www.nczonline.net/blog/2012/04/12/how-to-install-apache-ant-on-windows/

来源:http: //www.nczonline.net/blog/2012/04/12/how-to-install-apache-ant-on-windows/

回答by Mandeep Singh

You can follow these instrunctions-

您可以按照以下说明进行操作-

1)Download the latest version of ant from http://ant.apache.org/bindownload.cgi

1)从http://ant.apache.org/bindownload.cgi下载最新版本的ant

2)Unzip and save it to your C:\ directory as ant.

2) 解压并保存到你的 C:\ 目录中作为 ant。

3)Add the bin directory to your PATH environment variable.

3) 将 bin 目录添加到您的 PATH 环境变量中。

4)Add the ANT_HOME environment variable set to C:\ant.

4)将ANT_HOME环境变量设置为C:\ant。

you can use following commands to set ANT_HOME variable

您可以使用以下命令来设置 ANT_HOME 变量

C:>set ANT_HOME=C:\ant

C:>set JAVA_HOME=C:\jdk

C:>set PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin

C:>ant -version

Apache Ant version 1.8.1 compiled on April 30 2010

C:>set ANT_HOME=C:\ant

C:>set JAVA_HOME=C:\jdk

C:>set PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin

C:>ant -version

Apache Ant 1.8.1 版于 2010 年 4 月 30 日编译

if you have java installed on your machine

如果您的机器上安装了 java

5)Add the ANT_OPTS environment variable set to -Xmx256M.

5)添加ANT_OPTS环境变量设置为-Xmx256M。

This is all you need to install ant on your machine.

这就是在您的机器上安装 ant 所需的全部内容。