简体   繁体   English

如何安装 Apache Ant?

[英]How to install Apache Ant?

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.在这里我必须安装 Apache Ant,但我不明白如何安装。 I already download Apache Ant 1.7.1 , read manual ( http://ant.apache.org/manual/index.html )我已经下载了 Apache Ant 1.7.1,阅读手册 ( http://ant.apache.org/manual/index.html )

In here I must have RPM version from jpackage.org right?在这里我必须有来自 jpackage.org 的 RPM 版本,对吗? I already go to http://www.jpackage.org/ after that what must I do?我已经去http://www.jpackage.org/之后我该怎么办? 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.我已经尝试过( http://mirrors.dotsrc.org/jpackage/1.7/generic/free/repodata/ )和( http://www.jpackage.org/browser/browse.php?jppversion=1.7 )但是太多了关联。 I don't know witch one must I download我不知道我必须下载女巫

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

Step 1: Download and install第 1 步:下载并安装

Download Ant.下载蚂蚁。 Go to the Ant homepage and click to download the binary.转到Ant 主页并单击以下载二进制文件。 Because we're talking about Windows, choose to download the ZIP file rather than any of the others.因为我们谈论的是 Windows,所以选择下载 ZIP 文件而不是其他任何文件。 Scroll down to where it says “Current release of Ant” and click on the ZIP filename.向下滚动到显示“当前版本的 Ant”的位置,然后单击 ZIP 文件名。

Once downloaded, unzip the file.下载后,解压缩文件。 You'll now need to choose a permanent home for Ant on the computer.您现在需要在计算机上为 Ant 选择一个永久的家。 c:\java\ant is often used, but you can put it wherever you want. 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.对于 Windows XP:要在 Windows XP 上设置环境变量,请右键单击我的电脑并选择属性。 Then go to the Advanced tab and click the Environment Variables button at the bottom.然后转到高级选项卡并单击底部的环境变量按钮。

For Windows 7: To set environment variables on Windows 7, right click on Computer and select Properties.对于 Windows 7:要在 Windows 7 上设置环境变量,请右键单击计算机并选择属性。 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.您绝对需要的唯一环境变量是 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.在 Windows 7 上。您会注意到它们的路径中都有空格,这会导致问题。 You need to use the mangled name[3] instead of the complete name.您需要使用错位名称 [3] 而不是完整名称。 So for Windows XP, use C:\Progra~1\Java\jdk1.xx\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 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.为了能够在任何目录中运行 ant,Windows 需要知道 ant 二进制文件和 java 二进制文件的位置。 You'll need to add both of these to the end of the PATH variable.您需要将这两个都添加到 PATH 变量的末尾。 For Windows XP, you'll likely add something like this:对于 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/

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)解压并作为ant保存到你的C:\目录。

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:>设置 ANT_HOME=C:\ant

C:>set JAVA_HOME=C:\jdk C:>设置 JAVA_HOME=C:\jdk

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

C:>ant -version C:>ant 版本

Apache Ant version 1.8.1 compiled on April 30 2010 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 所需的全部内容。

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)解压并复制“c:\Program Files”中的“apache-ant-1.8.4”

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”进行检查。

the installation of ant and smslib is pretty simple. ant 和 smslib 的安装非常简单。 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.在 Linux 的情况下导出路径或将 ANT_HOME\bin 设置为 PATH 变量以从 shell 中的任何目录访问它。 ANT_HOME is the root directory where ant is installed. ANT_HOME 是安装 ant 的根目录。

For SMSLib Download the zip file and this link should guide you on a step by step basis对于 SMSLib 下载 zip 文件,此链接应逐步指导您

Sound's like you're using Linux.听起来就像你在使用 Linux。 If so, the easiest way would be to use a package management frontend like Synaptic and install ant in there.如果是这样,最简单的方法是使用像 Synaptic 这样的包管理前端并在其中安装 ant。

You can install Apache Ant with only single command on Ubuntu:您可以在 Ubuntu 上仅使用单个命令安装 Apache Ant:

sudo apt install ant

Check the version of ant installed with:检查安装的 ant 版本:

ant -version

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/ 一切都设置好了。无需设置环境变量。它会自动为你做每一件事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM