如何在 Windows 上设置 ANT_HOME?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9290243/
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
How to set ANT_HOME with Windows?
提问by Bekhbayar
How can I easily set ANT_HOME under Windows? I added "D:\Installz\apache-ant-1.8.2\bin;" to my system environment variable PATH and I also created an ANT_HOME variable.
如何在 Windows 下轻松设置 ANT_HOME?我添加了“D:\Installz\apache-ant-1.8.2\bin;” 到我的系统环境变量 PATH,我还创建了一个 ANT_HOME 变量。
采纳答案by Olivier.Roger
I expect you to be running on Windows (since you are using %
).
Simply add a new environment variable (Right-click on My Computer > Properties > Advanced > environment Variable) or using SET ANT_HOME=<path>
using command line (in that cas, it will only be active on that command line).
我希望您在 Windows 上运行(因为您使用的是%
)。只需添加一个新的环境变量(右键单击“我的电脑”>“属性”>“高级”>“环境变量”)或SET ANT_HOME=<path>
使用命令行(在该 cas 中,它只会在该命令行上处于活动状态)。
Once set you should be able to verify its value by doing echo %ANT_HOME%
in command line
设置后,您应该能够通过echo %ANT_HOME%
在命令行中执行来验证其值
The % sign around the variable indicates it is an environment variable.
变量周围的 % 符号表示它是一个环境变量。
For linux use the export ANT_HOME=<path>
in command line or in your ~/.profile(persistent, require logout/login). Use echo $ANT_HOME
for verification.
对于 linux,使用export ANT_HOME=<path>
in 命令行或~/.profile(持久,需要注销/登录)。使用echo $ANT_HOME
验证。
回答by aces.
In Windows7 you can go to Control Panel\All Control Panel Items\System
or right click on Computer and then to “Advance system setting”
在 Windows7 中,您可以转到Control Panel\All Control Panel Items\System
或右键单击计算机,然后单击“Advance system setting”
- Choose Advanced Tab
- Click "Environment Variables" button
- In System Variables, click "New" button
- Set Variable Name: ANT_HOMEand value as {directoryPath}\apache-ant-1.8.2(Ex:
D:\Installz\apache-ant-1.8.2
) - Click OK
Either click again on Newbutton if you do not have ‘Path' Variable in there
OR
Select it and edit by adding the value :
%ANT_HOME%\bin;
- Click OK
- To check if ANT is properly configured - In command prompt, type
ant -version
- It should give the ant version installed on your machine
- 选择高级选项卡
- 单击“环境变量”按钮
- 在系统变量中,单击“新建”按钮
- 设置变量名:ANT_HOME和值作为{目录路径} \阿帕奇-ANT-1.8.2(例如:
D:\Installz\apache-ant-1.8.2
) - 单击确定
如果那里没有“路径”变量,请再次单击“新建”按钮
或者
选择它并通过添加值进行编辑:
%ANT_HOME%\bin;
- 单击确定
- 检查 ANT 是否正确配置 - 在命令提示符下,键入
ant -version
- 它应该提供您机器上安装的 ant 版本
回答by PraveenMakam
I had a similar problem of installing JAVA JDK & ANT.
我在安装 JAVA JDK & ANT 时遇到了类似的问题。
I tried installing JDK this way.
我尝试以这种方式安装JDK。
Oracle site --> download JDK setup --> double click on the set up file (on your desktop) --> accept all defaults --> finish.
Oracle 站点 --> 下载 JDK 安装程序 --> 双击安装文件(在您的桌面上)--> 接受所有默认值 --> 完成。
we need to set environment variable in the deployment system. mycomputer (right click) --> properties --> advanced settings --> Environment variable --> system variable --> add new --> variable name: JAVA_HOME, Variable path: installation path of jdk on you computer --> click ok, ok.
我们需要在部署系统中设置环境变量。mycomputer(右键)-->属性-->高级设置-->环境变量-->系统变量-->新增-->变量名:JAVA_HOME,变量路径:jdk在你电脑上的安装路径-->单击确定,确定。
To check the successful installation of Java . windows + R --> cmd --> Java -Version you would see the response as below
检查 Java 是否安装成功。windows + R --> cmd --> Java -Version 你会看到如下响应
C:\Users\PRAX>java -version java version "1.6.0_38" Java(TM) SE Runtime Environment (build 1.6.0_38-b05) Java HotSpot(TM) 64-Bit Server VM (build 20.13-b02, mixed mode)
C:\Users\PRAX>java -version java version "1.6.0_38" Java(TM) SE Runtime Environment (build 1.6.0_38-b05) Java HotSpot(TM) 64-Bit Server VM(build 20.13-b02,混合模式)
This shows that you have successfully installed JDK & set an environment variable too.
这表明您已经成功安装了 JDK 并设置了环境变量。
ANT installation:
蚂蚁安装:
download ant file from http://ant.apache.org/bindownload.cgichoose a mirror & download the zip (zip is the easiest method to set)
从http://ant.apache.org/bindownload.cgi下载 ant 文件 选择镜像并下载 zip(zip 是最简单的设置方法)
unzip the file on your computer --> copy the path (traverse till bin folder).
在您的计算机上解压缩文件 --> 复制路径(遍历到 bin 文件夹)。
Now, we need to set an environment variable, Cmd --> set ANT_HOME = installation path --> press Enter if you have correctly entered, it wont throw any error. now execute, echo %ANT_HOME% you would see the result as your installation path.
现在,我们需要设置一个环境变量,Cmd --> set ANT_HOME = 安装路径 --> 如果你输入正确,按回车,它不会抛出任何错误。现在执行, echo %ANT_HOME% 你会看到结果作为你的安装路径。
your work is done.
你的工作完成了。
you can check the environment variable even in computer properties by default after executing the above set up.
执行上述设置后,您甚至可以在默认情况下在计算机属性中检查环境变量。
Hope, its useful.
希望,有用。
回答by rojanu
ANT_HOME is the path to your ant installation dir, in your case "D:\Installz\apache-ant-1.8.2" and JAVA_HOME is java install dir e.g. "C:\Program Files\Java\jdk1.7.0", that's on my machine
ANT_HOME 是您的 ant 安装目录的路径,在您的情况下为“D:\Installz\apache-ant-1.8.2”,而 JAVA_HOME 是 java 安装目录,例如“C:\Program Files\Java\jdk1.7.0”,就在我的机器
On Windows, %% (percent) symbols are used to signify variables.
在 Windows 上,%%(百分比)符号用于表示变量。
so to set both variables you can do either
所以要设置两个变量,你可以做任何一个
in command prompt, only valid for the session of the particular command propmt
在命令提示符下,仅对特定命令提示符的会话有效
SET ANT_HOME=D:\Installz\apache-ant-1.8.2
SET JAVA_HOME="C:\Program Files\Java\jdk1.7.0"
or go to System Properties -> Advanced -> Environment Variables and set to new variables
或转到 System Properties -> Advanced -> Environment Variables 并设置为新变量
回答by Rebse
A more flexible solution is to do all that 'environment stuff' in a batch file that starts your ant script, works also when there are no rights to change the environment variables.
See a similar questionthat came up recently for details.
更灵活的解决方案是在启动 ant 脚本的批处理文件中执行所有“环境内容”,在没有更改环境变量的权限时也可以使用。
有关详细信息,请参阅最近出现的类似问题。