C:\Users\WIN-10\Desktop>cd JAVAPROGRAM. JAVA
The system cannot find the path specified.
how to remove path system cannot specified
Answers
Run these:
C:\apache-tomcat-7.0.73\bin>echo %PATH%
C:\Windows\system32;C:\Windows;C:\Windows\System32\WindowsPowerShell\v1.0\;
To be honest, the error message makes sense if you read it, but we are so used to panic when we see the error, we don't try to understand the error message in first place. Now that, we have tried printing the value of PATH environment variable and seeing the message after few valid PATH, it suddenly starts making more sense.
The solution of "The system cannot find the path specified." Error
Now that you know the cause of this error is invalid directories and path in the PATH environment variable, you can easily solve this problem by finding and removing those invalid path entries which system is not able to found.
Btw, finding invalid path can be a problem too if you have several directories listed in PATH environment variable. In order to check every path is correct, you need to split the whole PATH String by semicolon and check if they are correct by copying and opening a directory in command prompt. This could be troublesome but it is the sure short way to find all invalid path in your PATH environment variable.
Can we do better? is there a way to omit some of the valid paths? Well, if you have paid close attention to the output of echo %PATH% command, you see it printed a couple of directories before throwing the "The system cannot find the path specified." error, which means they are valid, so we should start the search from the point point you see the error.
for example, in our case, the last valid path in the output above was "C:\Windows\System32\WindowsPowerShell\v1.0\;", so next path must be invalid. We can confirm that by copying that path and opening from the command prompt by just copy pasting it on run window and hitting enter.
If it opens a directory then it's a valid path, otherwise, run window will tell it's an invalid path. The next step is to correct or remove that path and run the echo %PATH% again. At this point, copy the invalid path by copying path after last valid path printed by echo %PATH% command and open that directory by using run command window or file explorer. If it's valid then it will open a directory otherwise you see the error, something like path doesn't exist.
Repeat the steps until the error completely goes aways,
if you are wondering how to see the value of PATH environment variable in Windows 8 or Windows 10, you can follow these steps to copy the PATH String and edit it to correct or remove invalid entries in PATH environment variables.
From your desktop, rick-click "My Computer" and click "Properties"
In the System Properties window, click on the Advanced tab.
In the Advanced section, click the Environment Variables button.
In the Environment Variables window, highlight the Path variable in the Systems Variable section and click the Edit button.
Solution
Here you can copy the value of PATH environment variable then you can search for last valid path e.g. "C:\Windows\System32\WindowsPowerShell\v1.0\;", then next path is your invalid PATH. Verify that by opening the directory using run command window or file explorer, if it's valid either correct it or remove it and then save and open a new command prompt to try again by running echo %PATH%.
If it throws "The system cannot find the path specified." error again means you have some more invalid paths in PATH environment variable. Just keep correcting or removing them until your PATH is printed completely by echo %PATH%. At this point, your PATH has only valid entries and you can tomcat or Java from the command line.
In my case, though the root cause was still invalid path in PATH environment variable, the reason of being invalid was quite interesting. My system PATH environment variable has sub-directories with an ampersand (&) character on it e.g. C:\Program Files (x86)\A & B\bin. When I copy pasted and open the directory from the file explorer or run window it was managed to open the directory but when I put the same path in PATH environment variable it was throwing the "The system cannot find the path specified." error.
I tried to escape & with backslash \ it didn't work then I tried to put single quote around A & B e.g. 'A & B', that didn't work too, finally I removed the directory from PATH because it wasn't really needed and boom the error "The system cannot find the path specified." was gone. Now the full path is printed when I type the path or echo %PATH% in command prompt. So, that resolved my problem.
Just remember that every time you make a change on PATH or Path environment variable under System Properties section, you must open a new command prompt window, don't run the PATH or echo %PATH% on old command prompt window because it will have old value of system properties. The new, updated value of PATH will only be available on new command prompt window.