运行,命令行和路径变量

时间:2021-06-06 23:06:52

I'm having a very weird issue with the command line and running Ant. I point the path variable at the location of my Ant bin directory (C:\Ant\bin) and when i go into a command window and type PATH it shows the location in it. But when I go to run Ant by typing "ant" it does nothing and states that it isn't recognized. But when I go to the run window (Windows+R) and type "ant" it runs it.

我在命令行和运行Ant时遇到了一个非常奇怪的问题。我将路径变量指向我的Ant bin目录(C:\ Ant \ bin)的位置,当我进入命令窗口并键入PATH时,它会显示其中的位置。但是当我通过键入“ant”来运行Ant时,它什么也没做,并声明它无法识别。但是当我进入运行窗口(Windows + R)并输入“ant”时,它会运行它。

I have restarted Windows twice and the problem still persists. I am running Windows Vista Ultimate with SP1 installed. I have tried "Running as Administrator" with no difference.

我已经重启Windows两次,问题仍然存在。我正在运行安装了SP1的Windows Vista Ultimate。我尝试过“以管理员身份运行”并没有区别。

Any one experience anything like this before?

以前有人经历过这样的事吗?

3 个解决方案

#1


Sometimes you can set a system-wide (or even just personal) Environment Variable and it'll cure it, as opposed to just setting it in your shell.

有时你可以设置一个系统范围(甚至只是个人)环境变量,它会治愈它,而不是只在shell中设置它。

Go to the Control-panel, then System, then Advanced, and look for the button on Environment Variables. From there, you can follow your nose.

转到“控制”面板,然后选择“系统”,再选择“高级”,然后查找“环境变量”上的按钮。从那里,你可以跟着你的鼻子。

Good luck.

#2


Ant also depends on Java to be on the path. Do you have that?

Ant也依赖Java来走上这条道路。你有吗?

I would also check to make sure the environment variables ANT_HOME and JAVA_HOME are set up properly in the console.

我还要检查以确保在控制台中正确设置了环境变量ANT_HOME和JAVA_HOME。

#3


Is there any chance that the command window you are trying to run Ant in is a different window to the cmd windwo where you set up and verify that its in the path? If the PATH is updated after a cmd window is already open it won't recongnise the change. Not clear if that might be your issue.

您尝试运行Ant的命令窗口是否有可能是与cmd windwo不同的窗口,您在其中设置并验证它在路径中?如果在cmd窗口已打开后更新PATH,则不会识别更改。不清楚这可能是你的问题。

If you are in the dir C:\Ant\bin and type "ant" does it recognise it?

如果你在目录C:\ Ant \ bin并输入“ant”它是否识别它?

#1


Sometimes you can set a system-wide (or even just personal) Environment Variable and it'll cure it, as opposed to just setting it in your shell.

有时你可以设置一个系统范围(甚至只是个人)环境变量,它会治愈它,而不是只在shell中设置它。

Go to the Control-panel, then System, then Advanced, and look for the button on Environment Variables. From there, you can follow your nose.

转到“控制”面板,然后选择“系统”,再选择“高级”,然后查找“环境变量”上的按钮。从那里,你可以跟着你的鼻子。

Good luck.

#2


Ant also depends on Java to be on the path. Do you have that?

Ant也依赖Java来走上这条道路。你有吗?

I would also check to make sure the environment variables ANT_HOME and JAVA_HOME are set up properly in the console.

我还要检查以确保在控制台中正确设置了环境变量ANT_HOME和JAVA_HOME。

#3


Is there any chance that the command window you are trying to run Ant in is a different window to the cmd windwo where you set up and verify that its in the path? If the PATH is updated after a cmd window is already open it won't recongnise the change. Not clear if that might be your issue.

您尝试运行Ant的命令窗口是否有可能是与cmd windwo不同的窗口,您在其中设置并验证它在路径中?如果在cmd窗口已打开后更新PATH,则不会识别更改。不清楚这可能是你的问题。

If you are in the dir C:\Ant\bin and type "ant" does it recognise it?

如果你在目录C:\ Ant \ bin并输入“ant”它是否识别它?