0

When i try to run this series of commands

cd \ && cd Users/gusenbauerM/IdeaProjects &
cd entities && rd /s /q target && mvn clean install -U && cd .. 

i get the following error from the last cd.. command

The command "cmd" is either misspelled or could not be found

My System Variables look like this:

JAVA_HOME    ->     C:\Program Files\Eclipse Foundation\jdk-11.0.12.7-hotspot
MAVEN_HOME   ->     C:\Program Files\apache-maven-3.8.4
M2_HOME      ->     C:\Program Files\apache-maven-3.8.4
PATH         ->     %MAVEN_HOME%\bin

Update

Like khmarbaise pointed out, i don't need the M2_HOME variable.

Also, I found out that the error is always displayed after running a Maven command, regardless of which one.

mvn -version

Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: C:\Program Files\apache-maven-3.8.4
Java version: 11.0.12, vendor: Eclipse Foundation, runtime: C:\Program Files\Eclipse Foundation\jdk-11.0.12.7-hotspot
Default locale: de_AT, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
The command "cmd" is either misspelled or could not be found
Max Gusenbauer
  • 217
  • 2
  • 12
  • The variables MAVEN_HOME nor M2_HOME needed. use only `PATH=%PATH%:C:\Program Files\apache-maven-3.8.4\bin` ... The cmd missing means you are calling that programatically... – khmarbaise Feb 01 '22 at 08:41
  • "The cmd missing means you are calling that programatically" Can you explain what you mean by that? @khmarbaise – Max Gusenbauer Feb 01 '22 at 08:52
  • After removing `MAVEN_HOME` maven commands are not working @khmarbaise – Max Gusenbauer Feb 01 '22 at 08:55
  • 1
    The directory separator on Windows is ``\`` and __not__ `/` as on Linux/Mac as explained by Microsoft on documentation page [Naming Files, Paths, and Namespaces](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file). So please use the backslash and not the forward slash in file/folder name strings. – Mofi Feb 01 '22 at 09:04
  • 1
    All the __CD__ commands should be concatenated together and improved to `cd /D "%USERPROFILE%\IdeaProjects\entities"`. `USERPROFILE` is a predefined Windows environment variable as explained, for example, on Wikipedia page about [Windows Environment Variables](https://en.wikipedia.org/wiki/Environment_variable#Windows). Open a command prompt window and run `set` to see all environment variables defined by default for your user account. Run `set user` to get just displayed all environment variables defined by default of which name starts case-insensitive with the string `user`. – Mofi Feb 01 '22 at 09:06
  • 1
    Run `set path` in a Windows command prompt window to see the __local__ environment variables `PATHEXT` and `PATH` which the Windows shell defines according to __system__ environment variable `Path` and `PATHEXT` and the __user__ environment variable `Path` if that one exists at all which is not the case by default on Windows. Please take a look on [What is the reason for "X is not recognized as an internal or external command, operable program or batch file"?](https://stackoverflow.com/a/41461002/3074564) It explains in full details the environment variables management on most important `Path` – Mofi Feb 01 '22 at 09:10
  • 1
    See my answer on [System cannot find path even though it exists in paths](https://stackoverflow.com/a/57442052/3074564) if you need to manually using the Windows GUI the __system__ and/or __user__ environment variable `Path`. Click once on Windows __Start__ button, type on keyboard `environment` and Windows offers two items: __Edit environment variables for your account__ and __Edit the system environment variables__. Click on the latter and make the necessary corrections. Another possibility is running __System Restore__ and restore the entire system before corruption of `Path`. – Mofi Feb 01 '22 at 09:14

1 Answers1

0

I found the solution to my problem. I did not add %MAVEN_HOME%\bin to the PATH variable (which replaced the actual one), i created a new PATH with variable, which only had the one value %MAVEN_HOME%\bin.

So Maven worked but i kinda broke everything else.

Max Gusenbauer
  • 217
  • 2
  • 12