I have a situation where I need to test a program with and without Java "installed". Instead of uninstalling and reinstalling for each test, I figured it would be ideal if I could simply disable the "java" command from working in cmd as this is the way the program determines if Java is installed. Is there an easy way to do this? I have tried removing any mentions of Java from the Environment variables (I'm on Windows 10 Education), but this does not seem to have had any effect. I am okay with hacky solutions as I just need this for my own quick tests on my machine.
Check the location of the java executabe with
c:\> where java
This may return multiple instances of java.exe in different directories of your PATH. Remove all returned directories from the PATH and restart your cmd.exe, because cmd will pick up changes in the environment variables only after it is restarted.
Remove all the paths of java from the environment variables(from user variables and System variables) then start cmd and type java, it should be unrecognised.
The standard path on Windows where Docker puts stuff is:
C:\Users\<USER>\.docker
We need to put it here:
D:\Docker
We couldn't find any info about where or how to change that setting. Any hint appreciated, thanks!
One solution that works for us is creating a symbolic link:
mklink /J "C:\Users\<USER>\.docker" "D:\Docker"
But it's not what we call a clean solution.
(All credit for the question & this answer goes to IMM0rtalis.)
You simply can define the environment variable HOME before launching a new boot2docker or docker machine session.
set HOME=D:\docker
(Add it to your user environment variables if you want it to persists across CMD sessions)
Those tools will look for any config in $HOME/.xxx
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.
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;
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...