Command 'cmd' not found, but there are 16 similar ones

Viewed 2971

I'm trying to run a java program on windows in VSCODE. When I click the run button at the top it opens the Java Process Console and runs the following command: $ cmd /C "c:\Users\user\.vscode\extensions\vscjava.vscode-java-debug-0.31.0\scripts\launcher.bat "C:\Program Files\AdoptOpenJDK\jdk-11.0.10.9-hotspot\bin\java.exe" -Dfile.encoding=UTF-8 @C:\Users\jbree\AppData\Local\Temp\cp_7gau2431e54dxprosf092viw9.argfile com.example.restservice.RestServiceApplication "

It then prints out: Command 'cmd' not found, but there are 16 similar ones., and I'm not too sure what to do afterwards.

3 Answers

I just ran into this exact issue! After some debugging, I found out it's because my terminal (in VS Code) was running off of WSL.

Make sure to check which terminal you're using! If you're trying to run Java locally, then you can configure a default shell ie. bash.

Let me know if this helps.

Edit: I also found this, not sure if it will help, but here you go! https://stackoverflow.com/a/58058378/11060097

your java debugger is using wsl. and most likely your java is installed on windows. not linux on windows. to fix this for me, i changed the settings for java debugging to use the external console. settings->java debugger->externalTerminal . this will then use the "external windows" setting for vscode. which should use cmd.exe (the windows shell, no linux).

This error happens because you probably have wsl has your standard terminal but it's probably configured to launch cmd using a windows path.

WSL won't understand what that windows path is, so you need to change it using a path structure it can understand

So

  1. hit Ctrl+, to hit the Settings screen

  2. type in terminal to see all the terminal settings You will see an option called Terminal> External:Windows Exec

  3. Change C:\Windows\System32\cmd.exe to /mnt/c/Windows/System32/cmd.exe

enter image description here

I had this error too and came here initially but I managed to figure out it was an incompatible path issue that was the cause.

Related