mvn command is not recognized as an internal or external command - maven

I am getting the mvn command not recognized as an internal or external command.
I have setup the M2_HOME, JAVA_HOME and added %M2_HOME%/bin to the path variable. All are system variables. Still getting the same problem.
Echoing the variables showing me the correct paths.
Path to Maven: C:\apache-maven-3.1.0\apache-maven-3.1.0
M2_HOME:C:\apache-maven-3.1.0\apache-maven-3.1.0
PATH: Other things,C:\Program Files (x86)\Java\jdk1.7.0_40\bin,C:\apache-maven-3.1.0\apache-maven-3.1.0\bin
and I have restarted my computer twice.

Right click on My Computer >> Properties >> Advanced system settings >>
System Properties window will get displayed
Under Advanced >> Environment Variables
Click on New to set Environment Variables
Variable name: JAVA_HOME
Variable value: C:\Program Files\Java\jdk1.8.0_121
Variable name: M2
Variable value: %M2_HOME%\bin
Variable name: M2_HOME
Variable value: C:\Program Files\Apache Software Foundation\apache-maven-3.5.0
Variable name: Path
Variable value: %M2_HOME%\bin
Then click on Ok, ok, ok.
Now restart you command prompt and check again with “mvn –version” to verify the mvn is running, you may restart your system also.
It should be working now.

Restart your machine, after setting up your M2_HOME (pointing to you Maven basedir, NOT the bin dir) and PATH (PATH=%M2_HOME%\bin;%PATH%).
Then do:
dir %M2_HOME%\bin\mvn*
If there is a .bat file, it should work under Windows, as it appears to be finding it. If there isn't one, then your paths are not right and you need to make sure your %PATH% variable really points to the correct path to Maven.
Make sure you are using the proper slashes for your OS. Under Windows they're \.

Write the entire maven path into the Environment PATH variable.
Example:
C:\Program Files\apache-maven-3.2.3\bin;
My PATH variable wasn't reading %M2% or %M2_HOME%\bin properly, and therefore I wrote the full path into the PATH variable.
Working.

This is worked for me:
1-download apache-maven-3.3.9-bin.tar.gz file from https://maven.apache.org/download.cgi
2-copy the folder under c:\programfiles
3-set variables as this:
M2_HOME ----- C:\Program Files\apache-maven-3.3.9
M2 ----- C:\Program Files\apache-maven-3.3.9
add Path variable to this: ;C:\Program Files\apache-maven-3.3.9\bin
then run the cmd as system admin
it worked.

I also was facing with the same issue still after adding path in environment variable and running it as a normal user in command prompt.
Then I opened command prompt and tried running as "Run as Administrator" and I was able to download all the packages with respect to the project.

Are you trying to reference a user variable in system variables? Try echo %path% and the M2 should have been fully expanded to show the file path to your Maven directory. If it hasn't, then that's the problem.
To fix it, you should create a user variable called PATH and add your %M2% reference into there.

Open Command prompt As "Run As a administrator" and try.

I have a stupid comment but someone else will have that issue. I was getting that same error when I was trying to put in ./mvnw clean package and I found out that I had to change it a bit to .\mvnw clean packageand I lived happily ever after.

Windows 10 -
Add new variable "M2_HOME" -
Update variable "path" -
Verify on cmd -

Try %M2_HOME%\bin (\ rather than /)

I faced this problem which kept me busy and buggy for quiet sometime. I was facing the problem (mvn not recognized) after setting up all required environment variables absolutely correctly. So by going by one of the response here, I switched to another version of maven and that fixed the problem.
Not being completely convinced why it worked this way, I then unzipped the problematic-version and updated env-vars which made it work.
The problem was when I initially extracted file from the zip, I modified the directory structure a bit. When you extract the zip, say apache-maven-X.x.x-bin.zip, it creates the folder structure as - "apache-maven-3.5.0-bin\apache-maven-3.5.0..."
In my first attempt I had modified this structure by deleting apache-maven-3.5.0-bin folder and bringing apache-maven-3.5.0 structure one folder up. This was causing the problem.

Try with echo %path% , if this option doesn't show your M2_HOME and others variable values as directory path, then create a new environment variable lets say PATH, and assign like below:
PATH=%JAVA_HOME%\bin;%M2_HOME%\bin
Add this in variable path=.....;%PATH%
Now open a new cmd, and try to echo %path%
it will show all thh system path
Now you can check mvn -version it will solve the problem , if not try to restart the system
P.S. as per doc, you should expend your zip distribution in C:\Program Files\Apache Software Foundation. But ideally it doen't matter

I'm using Maven 3+ version. In my case everything was fine. But while adding the M2_HOME along with bin directory, I missed the '\' at the end.
Previously it was like: %M2_HOME%\bin , which was throwing the mvn not recognizable error.
After adding "\" at the end, mvn started working fine. I guess "\" acts as pointer to next folder.
"%M2_HOME%\bin\" Should work, if you missed it.

Try setting the path of maven first through command prompt.
setpath.bat Open the cmd from the base window of the batch file.
The rest maven commands can be used once path is set through cmd.

One most important and often overlooked aspect is the %MAVEN_HOME%\bin or %M2_HOME%\bin should be the first thing in the %PATH% environment variable.

If you've already set the JAVA_HOME and M2_HOME (or MAVEN_HOME in my case) environment variables and added the \bin folder to the Path environment variable and still not working, then this solution could be for you.
Make sure that you have set your variables in the right order, your %JAVA_HOME%\bin folder should be added before the %MAVEN_HOME%\bin just like the shown image

I tried all way finally below step solved the issue .
In the downloaded zip there is file README , in that its mention that
for windows
set PATH="c:\program files\apache-maven-3.x.y\bin";%PATH%
create new PATH variable and assign first maven then %PATH%
it worked out for me .
Try It once

In your Environement variable :
new system variable:
M2_HOME Your mvn directroy "C:\......\bin"
new user variable:
M2 %M2_HOME%
edit the CLASSPATH by adding %M2%
finally open the cmd and write
path=%CLASSPATH%
enjoy

I had this same error but my problem was I had the following:
M2_HOME = C:\Program Files (x86)\Apache Software Foundation\apache-maven-2.2.1;
Which meant my PATH = %M2_HOME%\bin; (etc)
...became C:\Program Files (x86)\Apache Software Foundation\apache-maven-2.2.1;\bin
i.e. a semicolon was where it shouldn't be.
Which I discovered because Michael Ferry suggested using 'ECHO %PATH%' to see what the actual PATH output was.

I had the same problem. But just restarting my computer after setting up the Maven path resolved the issue.
Variable Name: M2_Home
Variable Value:C:\Apache\apache-maven-3.3.9
Variable Name: Path
Variable Value:C:\ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%JAVA_HOME%\bin\;%M2_HOME%\bin\

I faced similar problems. The article that helped me solve similar issues is by MKyong and is here: ****https://www.mkyong.com/maven/how-to-install-maven-in-windows/****
It is very important to include in maven's path the file that contains the 'bin','boot', 'conf', 'lib' etc. file folders. For example, in my case, the correct path is:
C:\Program Files\Apache Software Foundation\maven\apache-maven-3.5.0-bin\apache-maven-3.5.0

For me it was not working since I was editing Path variable in "User variable" and adding it under "System variable" made it work. Hope it helps.

For Windows you need to do the following:
Windows and type env
Open the edit environment panel
Click Environment Variables
In the system variables section, double click Path
In the dialog, create a System Variable under Path
like below ->
MVN_HOME: C:\Users<username>\Documents\Project\Software\apache-maven-3.6.3\bin
Open a new command prompt and hit mvn, you should be able to now.

I also faced the issue.
But the problem I faced was due to the location name where the maven was stored on system.
The path did contain spaces due to which system was not able to reach the path leading to this issue.
The issue got resolved for me when I moved the maven to a location which did not contain any spaces.

The existing answers are too complicated. I just fixed the same issue by
scoop install maven
That requires you install scoop the package manager for Windows in the first place.
However I recommend you install the scoop so that everything becomes easy.

Yeah so, for me, I fixed it by setting up the M2 variable.
MAVEN_HOME, JAVA_HOME and M2_HOME we set up with their paths, but the command, "mvn -verison" was still showing the error.
So I inserted one more variable, named, "M2" and then set the path of the maven folder (not the bin of the same) and ran the command in cmd.
It worked.

Adding environment variables from command prompt or windows powershell worked for me. I was able to verify the environment variables present using "set" command in command prompt.

You have written three paths above. The first path (path to maven) should be pointing to the bin directory.
Path to Maven: C:\apache-maven-3.1.0\apache-maven-3.1.0\bin;
Below are right. Above path should be corrected.
M2_HOME:C:\apache-maven-3.1.0\apache-maven-3.1.0;
PATH: Other things,C:\Program Files (x86)\Java\jdk1.7.0_40\bin,C:\apache-maven-3.1.0\apache-maven-3.1.0\bin;

Related

Running Kafka on Windows 10 fails: The system cannot find the path specified

I'm trying to run Kafka locally. I've got Zookeeper installed and running. I've downloaded the binaries for Kafka 2.11-1.1.0. I've adjusted the location of the logs in server.config, to a valid path. When I run .\bin\windows\kafka-server-start.bat .\config\server.properties, I get an error that says
The system cannot find the path specified.
I can see that both those files exist on my computer in the proper locations-what should I be troubleshooting?
I faced this issue while running the kafka-server-start.bat command. I double checked to ensure that there was no spaces in the kafka binaries path as well as correct syntax in JAVA_HOME.
Finally realized that the issue was due to a space in the JAVA_HOME path.
C:\Program Files\Java\jdk1.8.0_144
There is a space between Program and Files. I changed the directory of Java and updated the JAVA_HOME variable to
C:\Java\jdk1.7.0_51
This change solved my issue. I used the setx command to change the value in JAVA_HOME.
setx -m JAVA_HOME "C:\Java\jdk1.7.0_51"
I had this problem as well. In my case I have java installed in C:\Java\bin and JAVA_HOME defined as
JAVA_HOME=c:\Java\bin
I needed to change
c:\Tools\kafka_2.12-2.2.0\bin\kafka-run-class.sh
lines 224 to 229 from this
# Which java to use
if [ -z "$JAVA_HOME" ]; then
JAVA="java"
else
JAVA="$JAVA_HOME/bin/java"
fi
to this:
# Which java to use
if [ -z "$JAVA_HOME" ]; then
JAVA="java"
else
JAVA="$JAVA_HOME/java"
fi
because it was assigning java to C:\Java\bin/bin/java
which was then failing on 306 of the same file.
BTW: I'm using a git bash shell in windows. This allows me to run the bin/*.sh scripts instead of the bin/windows/*.bat scripts
Also I changes the value of the dataDir in
C:\Tools\kafka_2.12-2.2.0\config\zookeeper.properties
to
dataDir=C:\\Tools\\kafka_2.12-2.2.0\\zookeeper-data
I had the same problem, but it wasn't because of the malformed path of JAVA_HOME environment variable.
It was because I had extracted my kafka bineries in a path which contains spaces!
First it was here:
E:\Apache Kafka\kafka_2.11-2.1.0
Then I relocate it in this new path (which doesn't have any spaces!):
E:\ApacheKafka\kafka_2.11-2.1.0
And the problem resolved!
Hope this helps.
Turns out that this error is being thrown by kafka-run-class.bat because the path to JAVA_HOME in system variables is malformed (in my case, I had added /bin to it.) Removing /bin from the path, and having it be an existing Java installation folder, makes everything run fine.
As many have mentioned, this can happen if any of the kafka *.bat scripts that you run ( including zookeeper) refer to a bad JAVA_HOME system variable, or one containing a space.
You can solve this by changing JAVA_HOME to the shortened path name.
For example
set JAVA_HOME=C:\Progra~1\Java\jdk-11.0.1
P.S.
For convenience, I created a CMD desktop shortcut that sets the JAVA_HOME to be right for Kafka, and CDs to my kafka installation. My Desktop shortcut is as follows:
%windir%\System32\cmd.exe /k set JAVA_HOME=C:\Progra~1\Java\jdk-11.0.1& f: & cd f:\kafka\kafka_2.12-2.2.0
To add to the existing answer, you can also get the error when running the Kafka provided zookeeper-server-start command (and almost all other scripts in the bin/windows folder) because it also utilizes kafka-run-class, and therefore relies on a valid JAVA_HOME environment variable path.
cd D:\Downloads\kafka
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
Late reply, but I hope it helps someone. I had the same issue, and found someone had updated JAVA to a newer version, i.e. my JAVA_HOME system variable was pointing to a folder that didnt exist. Strange as I hadnt done it, but the answers above inspired me to check it.
I facing same issue and fixed with below steps as following:
Make sure your environment variable as:
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_261
ZOOKEEPER_HOME=C:\apache-zookeeper-3.6.2
KAFKA_HOME=C:\kafka_2.13-2.7.0
Edit the 'Path' in system variable and type:
%JAVA_HOME% / bin, %ZOOPKEEPER_HOME / bin and %KAFKA_HOME% / bin
Now, open the terminal, Run zoopkeeper and kafka
For Zoopkeeper: zkserver
For Kafka: bin\windows\kafka-server-start.bat .\config\server.properties
It runs without an any issues and errors.
I think JAVA_HOME should keep till JDK path not JDK\bin.
I had been stuck with this for quite some time. Following are the steps I followed to resolve the issue:
In enviroment variables set JAVA_HOME to C:\Program Files\Common Files\Oracle\Java\javapath
If the above doesn't resolve the issue, check if in kafka/bin/kafka-run-class.sh JAVA=$JAVA_HOME/bin/java is used. In this case you might need to simply create a folder bin under javapath and copy the java.exe to it. This should fix the isssue.
I tried all the solutions, I changed JAVA_HOME different methods and it didn't work.
Solution:
launch cmd.exe as administrator and execute the command:
set JAVA_HOME=%ProgramFiles%\Java\jdk-17.0.1
(only will choice your jdk version)
In the case of main, in Environment variables set JAVA_HOME in Both part
User variables & system variables And the problem resolved!
Make sure your java_home path is correct with respect to the directory. This issue happens when the java_home path is wrong.
I relocate it into the new path and I provide this zookeeper bin path properly into environment variable setup and it work for me fine.
A simple solution that worked for me -
Open kafka-run-class.sh file, goto line num 306, enclose $JAVA within "".
exec "$JAVA" $KAFKA_HEAP_OPTS $KAFKA_JVM_PERFORMANCE_OPTS $KAFKA_GC_LOG_OPTS $KAFKA_JMX_OPTS $KAFKA_LOG4J_OPTS -cp $CLASSPATH $KAFKA_OPTS "$#"
This problem appears if there a space in your Java path. Either remove the space from your Java installation path or enclose the path within double-quotes.

JMETER_HOME environment variable is not defined

I tried to execute JMeter 4.0 from the command prompt in Windows 7.
I got the following error during execution:
The JMETER_HOME environment variable is not defined correctly This
environment variable is needed to run this program
I set C:\apache-jmeter-4.0\bin to JMETER_HOME variable, but the problem remains
I can start JMeter with its jar file.
I use jdk1.8.0_162 and set JAVA_HOME environment variable correctly.
You should set JMETER_HOME to main JMeter directory as C:\apache-jmeter-4.0
Also don't set JMeter directory to JAVA_HOME variable (should hold Java installation path)
Ensure you have installed Java and JMETER Gui works fine first.
Then,
At User Variables add JMETER_HOME followed by D:\Jmeter (Where Jmeter is installed)
Next select Path in User variables and add D:\Jmeter\bin(Where Jmeter bin path is)
Save and restart cmd.
P.S: This is for Windows solution
First ensure you've Java installed
Second you need to ensure the working directory of your call is the JMeter installation directory.
Assumption your JMeter installation is located under:
C:\Program Files (x86)\apache-jmeter-4.0
then you need to set this as working directory.
As you can read in the jmeter.bat file itself:
JMETER_HOME - installation directory. Will be guessed from location of jmeter.bat
This might sound obvious, but I'm getting this error on machines that don't have Java installed. Of course, though a better message might have been nice!
Easiest way:
just delete the JMETER_HOME environment variable, run jmeter.bat and variable will be added automatically.
Asually a wrong JMETER_HOME entry causes this. make sure you have JMETER_HOME pointed to jmeter folder not inside bin directory. For example ,from my local windows i am able to see this thie environment variable
Type : echo %JMETER_HOME%
For me, setting the Windows environment variable didn't help. Instead it worked when I set the variable at the command line (using the root folder of jmeter).
Like this:
SET JMETER_HOME=C:\apache-jmeter-4.0
ensure java is installed and can check with java —version
assuming the path jmeter installed is C:\apache-jmeter-5.3
add the user variable
press new
add Jmeter variable name as JMETER_HOME
variable value as: C:\apache-jmeter-5.3
add the path
look for Path system variable and press edit
edit it to have C:\apache-jmeter-5.3\bin
it doesnt have Path(very unlikely), than press new and add variable name as path and value as C:\apache-jmeter-5.3\bin
restart cmd and type jmeter should do the job.
One reason for getting this error is to have JMETER_HOME variable defined in the environment variables but pointing to the wrong location. I had this problem due to previous installation.
You don't need to set JMETER_HOME path explicitly under user variables, just add/change under system variables under path variable as your bin path. If you already have earlier version of JMeter just append with latest version. Path looks like : C:\XXX\apache-jmeter-4.0\bin

Postgres "psql not recognized as an internal or external command"

For Postgres, I keep getting this error multiple times even though I have already set the location of the bin folder to the path variable in Windows 8. Is there something else I'm missing?
(I can't post pictures since I don't have enough reputation)
Just an update because I was trying it on Windows 10 you do need to set the path to the following:
;C:\Program Files\PostgreSQL\14\bin ;C:\Program Files\PostgreSQL\9.5\lib
PS : 14 is the current version, check whatever version you are on.
You can do that either through the CMD by using set PATH [the path]
or from my
computer => properties => advanced system settings=> Environment
Variables => System Variables
Then search for path.
Important: don't replace the PATHs that are already there just add one beside them as follows ;C:\Program Files\PostgreSQL\9.5\bin ;C:\Program Files\PostgreSQL\9.5\lib
Please note: On windows 10, if you follow this: computer => properties => advanced system settings=> Environment Variables => System Variables> select PATH, you actually get the option to add new row. Click Edit, add the /bin and /lib folder locations and save changes.
Then close your command prompt if it's open and then start it again
try psql --version
If it gives you an answer then you are good to go if not try echo %PATH% and see if the path you set was added or not and if it's added is it added correctly or not.
Important note:
Replace 9.5 with your current version number. As of 2021, that is 13.
For 2022 is 14.
Windows 10
It could be that your server doesn't start automatically on windows 10 and you need to start it yourself after setting your Postgresql path using the following command in cmd:
pg_ctl -D "C:\Program Files\PostgreSQL\11.4\data" start
You need to be inside "C:\Program Files\PostgreSQL\11.4\bin" directory to execute the above command.
EX:
You still need to be inside the bin directory to work with psql
Enter this path in your System environment variable.
C:\Program Files\PostgreSQL\[YOUR PG VERSION]\bin
In this case i'm using version 10. If you check the postgres folder you are going to see your current versions.
In my own case i used the following on separate lines:
C:\Program Files\PostgreSQL\10\bin
C:\Program Files\PostgreSQL\10\lib
You can follow the following steps below.
C:\Program Files\PostgreSQL\yourversion
I had your issue and got it working again (on windows 7).
My setup had actually worked at first. I installed postgres and then set up the system PATH variables with C:\Program Files\PostgreSQL\9.6\bin; C:\Program Files\PostgreSQL\9.6\lib. The psql keyword in the command line gave no errors.
I deleted the PATH variables above one at a time to test if they were both really needed. Psql continued to work after I deleted the lib path, but stopped working after I deleted the bin path. When I returned bin, it still didn't work, and the same with lib. I closed and reopened the command line between tries, and checked the path. The problem lingered even though the path was identical to how it had been when working. I re-pasted it.
I uninstalled and reinstalled postgres. The problem lingered. It finally worked after I deleted the spaces between the "; C:..." in the paths and re-saved.
Not sure if it was really the spaces that were the culprit. Maybe the environment variables just needed to be altered and refreshed after the install.
I'm also still not sure if both lib and bin paths are needed since there seems to be some kind of lingering memory for old path configurations. I don't want to test it again though.
If you tried all the answers and still spinning your heads, don't forget to change the version with your one which you downloaded.
For example, don't simply copy paste
;C:\Program Files\PostgreSQL\9.5\bin ;C:\Program Files\PostgreSQL\9.5\lib
More clearly,
;C:\Program Files\PostgreSQL\[Your Version]\bin ;C:\Program Files\PostgreSQL\[Your Version]\lib
I was spinning my heads. Hope this helps.
Make sure that the path actually leads to the executables. I'm using version 11 and it did not work until this was set as the path:
C:\Program Files\PostgreSQL\11\bin\bin
Maybe this is how version 11 is structured or I somehow botched the installation but I haven't had a problem since.
Even if it is a little bit late, i solved the PATH problem by removing every space.
;C:\Program Files\PostgreSQL\<installed version>\bin;C:\Program Files\PostgreSQL\<installed version>\lib
works for me now.
Simple solution that hasn't been mentioned on this question: restart your computer after you declare the path variable.
I always have to restart - the path never updates until I do. And when I do restart, the path always is updated.
Find your binaries file where it is saved. get the path in terminal mine is
C:\Users\LENOVO\Documents\postgresql-9.5.21-1-windows-x64-binaries (1)\pgsql\bin
then find your local user data path, it is in mostly
C:\usr\local\pgsql\data
now all we have to hit the following command in the binary terminal path:
C:\Users\LENOVO\Documents\postgresql-9.5.21-1-windows-x64-binaries (1)\pgsql\bin>pg_ctl -D "C:\usr\local\pgsql\data" start
done!
Always better to install a previous version or in the installation make sure you specify the '/data' in a separate directory folder "C:\data"
For Windows 10 and 11 users, here are the steps:
Go to Edit environment variables for your account (search for it on the start menu)
It will open the System Properties form — click the Environment Variables
Under the User variables for <username> (or you can add it in system variables), find the path variables and click edit, and add the path to your Postgres bin file address (in my case it's C:\Program Files\PostgreSQL\15\bin).
And save it and re-open the terminal.

Maven 3.0.5 installed in Windows 7 but not able to run through command prompt

As per suggestions given in this site i have added the required variables and values as below too but no response
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_25
M2=%M2_HOME%\bin
M2_HOME=C:\Program Files\apache-maven-3.0.5-bin\apache-maven-3.0.5\bin
PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%M2_Home%\bin
Please help me
Your path configuration has a M2_Home instead of M2_HOME. It should be all uppercase
%M2_HOME%
Also notice, you are specifying bin twice, should
M2_HOME=C:\Program Files\apache-maven-3.0.5-bin\apache-maven-3.0.5
I had same situation multiple times, i.e. configured M2_HOME as user env variable and added it to PATH (system env variable), i.e.
PATH=%M2_HOME%\bin; ...
However sometimes (randomly) Windows don't resolve variable in path, run "echo %PATH%" in your console. In my case I can still see %M2_HOME% there instead of resolved path to maven installation directory. It seems to be a bug in Windows itself, which is present in WinXP and Win7 at least.
I have resolved it as follows:
Open env variables, change M2_HOME (user one) to correct value. Press OK to save and close window
Open env variables again, now open PATH (system one) variable details, make sure M2_HOME is there and press OK, i.e. just save without any modification.
Now, open command line and check "echo %PATH%" - there should be resolved path. Confirm by running "mvn --version".
I know it really sounds like a black magic, but it should work...

‘ant’ is not recognized as an internal or external command

I have the same issue as this user: ant - not recognized as an internal
however unfortunately none of the solutions have worked for me in that post or any other. I've also looked at other commands not recognized and specifically adding a path variable. The procedure I am using is as follows:
Extract to a desired installation directory, e.g. C:\apache-ant
Create an ANT_HOME environment variable`
Open System Properties -> Advanced -> Environment Variables
Create a new system variable
Variable name: ANT_HOME
Variable value: C:\apache-ant
Add %ANT_HOME%\bin directory to the PATH system variable
Open System Properties -> Advanced -> Environment Variables
Under system variables, select PATH and append ;%ANT_HOME%\bin
e.g. %SystemRoot%\system32;%SystemRoot%;%JAVA_HOME%\bin;%ANT_HOME%\bin
Verify that ANT is installed.
Open a new command window and type:
C:\>ant -v`
In my case the Variable value is C:\apache-ant\apache-ant-1.8.2.
My exact path variable is %SystemRoot%\system32;%SystemRoot%;%JAVA_HOME%\bin;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%JAVA_HOME%\bin;%ANT_HOME%\bin which doesn't have any spaces between semicolons.
However testing the ant installation does not work, the picture below is what I'm experiencing:
I have tried restarting on numerous occasions to no avail. I have run out of ideas, so if anyone has any any information would be helpful. Thanks!
EDIT
Posted results of dir:
ANT_HOME is not being resolved. Change %ANT_HOME%\bin in the Path system environment variable to c:\apache-ant\apache-ant-1.8.2\bin.
I had a similar issue, but the reason that %ANT_HOME% wasn't resolving is that I had added it as a USER variable, not a SYSTEM one. Sorted now, thanks to this post.
create a script including the following;
(replace the ant and jdk paths with whatever is correct for your machine)
set PATH=%BASEPATH%
set ANT_HOME=c:\tools\apache-ant-1.9-bin
set JAVA_HOME=c:\tools\jdk7x64
set PATH=%ANT_HOME%\bin;%JAVA_HOME%\bin;%PATH%
run it in shell.
When Environment variables are changed log off and log in again so that it will be applied.
I downloaded ant (http://ant.apache.org/bindownload.cgi), unzipped to my C drive, and used the windows 'doskey' command:
doskey ant=C:\apache-ant-1.9.6\bin\ant.bat $*
this will work as long as you use the same command console, to make it permanent is more difficult: http://darkforge.blogspot.com/2010/08/permanent-windows-command-line-aliases.html
Please follow these steps
In User Variables
Set VARIABLE NAME=ANT_HOME VARIABLE PATH =C:\Program Files\apache-ant-1.9.7
2.Edit User Variable PATH = %ANT_HOME%\bin
Go to System Variables
Set Path =%ANT_HOME%\bin
Had the same problem. The solution is to add a \ at the end of %ANT_HOME%\bin so it became %ANT_HOME%\bin\
Worked for me. (Should be system var)
even with the environment variables set, I found that ant -version does not work in scripts. Try call ant -version
Need to see whether you got ant folder moved by mistake or unknowingly.
It is set in environment variables.I resolved this once as mentioned below.
I removed ant folder by mistake and placed in another folder.I went to command prompt and typed "path". It has given me path as "F:\apache-ant-1.9.4\".
So I moved the ant back to F drive and it resolved the issue.
If none above helped anyone...My issue was that I was trying to use ant -version on a cmd prompt that I had already opened before I added apache-ant to the path.
As the cmd prompt was using the PATH it had when it was opened and not the new one (that had apache-ant) it wasn't finding it.
Opening a new cmd and running ant -version showed me I actually did have it installed correctly.
I got same problem , what I did for fix :
Open system environment variable
Click on environment variable
in user varaible -> edit path and then add C:\FolderWhereYouInstalled\ant\ant_1.8.4\bin
Click ok
Open cmd and type : ant -version
thanks, might help someone :)

Resources