环境变量错误 - 未被识别为内部或外部命令 [英] Environment Variable errors - not recognized as an internal or external command

查看:30
本文介绍了环境变量错误 - 未被识别为内部或外部命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一次重写,以巩固我在寻找解决问题的答案时所学到的知识.我已经安装了 Ant.当我在命令行上使用ant"时,我收到消息ant 不是内部或外部命令,也不是可运行的程序或批处理文件."我很快确定这是一个我的环境变量有问题.

This is a rewrite to consolidate what I have picked up searching for answers to resolve my problem. I had installed Ant. When I used "ant" on the Command Line, I got the message "ant is not recognized as an internal or external command, operable program or batch file." I quickly established this was a problem with my Environmental Variables.

我假设您已经获得有关更改环境变量的说明.下面的要点涵盖了那些编写说明没有告诉你的挑剔的部分,即假定的知识.我建议在尝试解决此问题时仅通过它们.

I am assuming you have already got instruction on changing your Environmental Variables. The bullet points below cover the finicky bits, the assumed knowledge, that those writing instructions do not tell you. I suggest just stepping through them when trying to resolve this.

知道我运行的是 Windows7 是很重要的.这些要点对于 Windows 来说可能相当普遍,但我将其留给读者来确定.

It will be important to know I am running Windows7. These points are likely fairly universal for Windows, but I leave that for the reader to establish.

如果您的问题仍未解决,请创建一个新问题,或许可以参考这个问题.不要就这个问题寻求帮助,因为它已经解决了.找到的其他解决方案可以在这里添加(或发布,我会添加它们).

If your issue is still not resolved, please create a new question, perhaps referring back to this one. Do not ask for help on this question as it has been resolved. Other solutions found though can be added here (or posted & I will add them).

一旦您可以从命令行获取版本号(例如:ant -version"或java -version"),您就解决了环境变量问题.在那之后,你有一个不同的问题.我花了额外的 2 个小时试图修复"Buildfile:build.xml 不存在!构建失败"命令行错误,但没有意识到这意味着这个问题已经解决,我已经转移到另一个问题上.

You have solved the Environmental Variable problem once you can get a version number from the Command Line (eg: "ant -version" or "java -version"). After that, you have a different problem. I spent an extra 2 hours trying to 'fix' a "Buildfile: build.xml does not exist! Build failed" Command Line error, not realising that meant this problem was fixed and I had moved onto another one.

最后一条建议.使用它时,将整个 PATH 变量复制并粘贴到安全的地方.如果你不小心点击了删除",你就没有机会恢复,这可能会导致很多痛苦.

One last piece of advice. Copy and paste your entire PATH variable to somewhere safe while you are playing with it. If you accidentally hit "Delete", you do not get an opportunity to recover and that could lead to a lot of pain.

逐步完成这些;

  • 关闭所有打开的命令行控制台(Windows 控制台)并重新启动它.这将重置变量,每次更改环境变量时都需要执行此操作.
  • 确保您在环境变量中没有留下空格.末尾没有空格,变量之间也没有空格.
  • 检查您的拼写是否一致,并检查您的位置是否正确.
  • 将新文本添加到 PATH 变量的开头,而不是结尾.如果您多次添加它,这可以避免与其他内容发生冲突和任何问题.它在第一次成功时停止阅读.
  • 确保 PATH 变量在新添加的文本和现有文本之间插入了一个分号(;")(没有空格).

如果命令行echo %JAVA_HOME%"返回%JAVA_HOME%",那么您可能有权限问题(使用您的 %variable% 而不是我的 %JAVA_HOME%);

If Command Line "echo %JAVA_HOME%" returns "%JAVA_HOME%", then you possibly have a permissions issue (use your %variable% not my %JAVA_HOME%);

  • 将新变量(例如JAVA_HOME"或ANT_HOME")及其路径放入系统变量中.从用户变量中删除它.

使用用户变量是我必须解决的最后一个问题.奇怪的是,echo %JAVA_HOME%"很好,但是echo %ANT_HOME%"返回了%ANT_HOME%".

Using User variables was the last problem I had to fix. Bizarrely "echo %JAVA_HOME%" was fine, but "echo %ANT_HOME%" returned "%ANT_HOME%".

最后,如果一切都失败了;

Finally, if all else fails;

  • 重启你的电脑
  • 获取软件的新副本,安装并重新启动.

我感谢那些帮助 &以前的 Stack Overflow 作者,我阅读了他们的帖子,试图找到解决方案.

My thanks to those that helped & the previous Stack Overflow authors whose posts I read trying to find solutions.

推荐答案

Windows 控制台需要重新启动才能应用在环境变量中所做的更改

Windows console need to be restarted to apply changes made in environment variables

这篇关于环境变量错误 - 未被识别为内部或外部命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆