在 Windows 7 中为 java 和 ant 设置环境变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9673871/
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
setting up environment variables in windows 7 for java and ant
提问by geoff swartz
I have a book that says to do the following.
我有一本书说要做以下事情。
- Add a JAVA_HOME and ANT_HOME environment variable. - check
- Add $JAVA_HOME/bin and $ANT_HOME/bin to my path variable - check
- 添加 JAVA_HOME 和 ANT_HOME 环境变量。- 查看
- 将 $JAVA_HOME/bin 和 $ANT_HOME/bin 添加到我的路径变量 - 检查
When I then go to the command prompt and try ant -version it says ant is not a recognized command. If I then take the value I plugged into the ANT_HOME variable and use it in place of $ANT_HOME it all works. Is this the way it's supposed to work in windows? I'm not sure so I just figured that whatever was put in ANT_HOME was then parsed in the path variable when used as $ANT_HOME. Thanks.
当我转到命令提示符并尝试 ant -version 时,它说 ant 不是可识别的命令。如果我然后将插入到 ANT_HOME 变量中的值用于代替 $ANT_HOME ,则一切正常。这是它应该在Windows中工作的方式吗?我不确定,所以我只是想在用作 $ANT_HOME 时会在路径变量中解析放在 ANT_HOME 中的任何内容。谢谢。
采纳答案by Bogdan Emil Mariesan
you can try the following:
您可以尝试以下操作:
SET ANT_HOME=my_path_to_ant_folder
SET JAVA_HOME=my_path_to_jdk_folder
SET PATH=%PATH%;%ANT_HOME%/bin;%JAVA_HOME%\bin;
回答by JB Nizet
$ANT_HOME doesn't mean $ANT_HOME, literally. $ANT_HOME means "the value of ANT_HOME".
从字面上看,$ANT_HOME 并不意味着 $ANT_HOME。$ANT_HOME 的意思是“ANT_HOME 的值”。
If Ant is installed at c:\ant
, your environment variables should be:
如果 Ant 安装在c:\ant
,您的环境变量应该是:
ANT_HOME=c:\ant
PATH = ...;c:\ant\bin;...
ANT_HOME=c:\ant
PATH = ...;c:\ant\bin;...
Same for JAVA_HOME.
JAVA_HOME 也一样。
回答by Amir Pashazadeh
- right click My Computer
- click Properties
- go to Advanced system settings
- click on Advancedtab
- click on Environment Variables
- click on New...
- 右键单击我的电脑
- 单击属性
- 进入高级系统设置
- 单击高级选项卡
- 点击环境变量
- 点击新建...
Now you can define an environment variable, type JAVA_HOMEin Variable nameand in Variable valuethe path to you JAVA_HOME, the same thing goes for ANT_HOME.
现在你可以定义一个环境变量,在变量名中输入JAVA_HOME,在变量值中输入你的路径 JAVA_HOME ,同样的事情也适用于ANT_HOME。
回答by ibrowiz
Right click on My computer and select properties.
右键单击我的电脑并选择属性。
Click on Advance system settings.
单击高级系统设置。
Visit http://codebrizz.blogspot.com.ng/2016/07/installation-and-configuration.htmlfor full configuration guide with images for each step
访问http://codebrizz.blogspot.com.ng/2016/07/installation-and-configuration.html获取完整的配置指南,每一步都有图片