Maven isn't installing properly - maven

I've tried everything I could find on this topic, yet I'm not able to install Maven.
I'm at the following point:
I have java installed
I unzipped the files from the apache website
I have set up environment variables and added requirement parameters to the path (had to use the escape character in the path, because of the space in Program Files folder name: C:\Program^ Files\apache-maven-3.6.3)
what could be the problem?
cmd

From the attached image all requirements are OK. Try one of those two solutions:
Close the CMD window and reopen it (if you didn't this already).
Restart your computer in in order to apply the environment variables you've just added.

Related

How to temporarily disable the "java" command in cmd

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.

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.

mvn command is not recognized as an internal or external command

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;

Apache Maven installation in windows 8

I followed steps mentioned in this link http://maven.apache.org/download.cgi
Whenever I type mvn --version in cmd.
I got 'mvn' is not recognized as an internal or external command, operable program or batch file.
But when I opened cmd with "Run as a administrator" it worked.
OS: windows 8
How can I run mvn for any user on windows 8.
Try setting the environment variable M2 as System variable instead of User variable.
I used Rapid Environment Editor, started as an Administrator, and put these variables into my System path, and this problem went away.
For some reason, when I added the the JDK, JRE, and Maven bin folders to my Path through the Windows utility, it didn't work. Rapid Environment Editor told me that the variables were not valid or I did not have access to them. Windows 8 seems to be really picky about administrator rights and I guess they didn't think that through very well.
Just be sure to start Rapid Environment Editor as an administrator, and re-open your command windows when you save your changes.
I had to move the installation directory of Maven into C:\Users*your_username*, so that Maven no longer required admin permissions. The PATH variables started working after that.
Set the MAVEN/M2 and MAVEN_HOME/M2_HOME variables in the environment variables in windows 8, this will solve the problem.
I'm using chinese version so that i'm not sure what's these word in english version.
click right button on "My computer"
click last item on list
click "Advanced system setting" at left side
"Evironment Variable"
append maven's bin directory into system's environment variables path
after all, try linux
The simplest way is:
Add maven directory to the path in systems variable.
don't add anything in user variable and no need to add any variable.
faced the same problem; The bins or files from path for M2_home and Java_home need to be found in a directory where the user has full control permission. Change the security permission settings of the user through the administrator by right click on the order, go to properties->security tab and check the Full control box for "authenticated user" and "user".

How to change Jenkins default folder on Windows?

How to change Jenkins default folder on Windows where Jenkins runs as Windows service.
I want to change C:\Users\Coola\.jenkins folder to d:\Jenkins due to lack of space on C: partition (Every build takes ~10MB of free space). I don't want to reinstall Jenkins as Windows service. I just want to change folder of existing Jenkins instance. In case of lack of global solution I could focus only on relocating jobs folder.
Thanks in advance for your help.
Stop Jenkins service
Move C:\Users\Coola\.jenkins folder to d:\Jenkins
Using regedit, change HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Jenkins\ImagePath to "d:\Jenkins\jenkins.exe"
Start service
Apparently, grams' answer works but is not preferred. In Windows software and data/configuration files are supposed to reside in different places. This should be well known to Unix guys, it is basically like having a home directory. However, the wording with regard to JENKINS_HOME is broken anyways as setting an environment variable does not help despite what is being said in the help text.
I used the procedure that is described here: http://tech.nitoyon.com/en/blog/2014/02/25/jenkins-home-win/
Basically:
Stop Jenkins service
Edit entry <env name="JENKINS_HOME" value="%BASE%"/> in jenkins.xml in the Jenkins installation directory. This will be something like C:\Program Files (x86)\Jenkins. In your case value has to be set to d:\Jenkins
Move Files from the installation directory to the new destination, d:\Jenkins, all except (some of them may not exist in a fresh installation)
jre folder
jenkins.err.log
jenkins.exe
jenkins.exe.config
jenkins.out.log
jenkins.war
jenkins.war.bak
jenkins.war.tmp
jenkins.wrapper.log
jenkins.xml
Restart the service again.
When you read Administering Jenkins you can read all options how to modify the JENKINS_HOME environment variable.
On this website you can read how to configure you Tomcat container to override the JENKINS_HOME environment variable, they advise to create the file $CATALINA_BASE/conf/localhost/jenkins.xml, with the following content:
<Context docBase="../jenkins.war">
<Environment name="JENKINS_HOME" type="java.lang.String" value="/data/jenkins" override="true"/>
</Context>
Here is the answer that worked for me: Jenkins: How to change JENKINS_HOME on Windows
And in addition to grams answer, the most important part is creating an environment variable named JENKINS_HOME with value "D:\Jenkins". Without that, on starting Jenkins it would again create the .jenkins folder in your user home folder.
I was able to change the JENKINS_HOME variable following this http://tech.nitoyon.com/en/blog/2014/02/25/jenkins-home-win/
Setting JUST %JENKINS_HOME% as windows system wide environment variable didn't have any effect!
We installed by dropping the .war into Tomcat, and could set home by just setting the environment variable JENKINS_HOME (with a service restart).

Resources