Matt Stevens
Matt Stevens

Reputation: 1124

Environment Variable errors - not recognized as an internal or external command

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.

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).

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.

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.

Step through these;

If Command Line "echo %JAVA_HOME%" returns "%JAVA_HOME%", then you possibly have a permissions issue (use your %variable% not my %JAVA_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;

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

Upvotes: 2

Views: 27072

Answers (3)

Nikolay Ivanov
Nikolay Ivanov

Reputation: 8935

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

Upvotes: 5

David M
David M

Reputation: 2541

JAVA_HOME is the environmental variable that java uses. you know you have it right when you type java -version and get what you expect (1.7.x). the PATH variable just allows you to type in a binary name (that's found on the PATH) without prefixing it with the path-to-the-binary/binary.

Upvotes: 2

rekire
rekire

Reputation: 47985

That output means the the environment variable is not set. You can do this in the console with:

set variable=value

Or better go to your system settings and set them permanently. See also this site how to set them.

Upvotes: 3

Related Questions