‘cmd’ is not recognized as an internal or external command, operable program or batch file


#1

I get this error when I try and run any Java program I cant seem to find how to fix this can anybody help me?

Thank you.


#2

Atom has no ability to run code, so you must be using a package. When you’re asking a question about a package, please make sure to identify that package. You should also always identify your operating system just in case the person reading the post doesn’t know when the text of the error message is Windows-specific.

What happens if you open the Run window (Win + r) and type cmd? Do you have Java installed? You should also post a screenshot of one of the files you’re trying to run (don’t crop it; post the whole Atom window so that we can see everything that’s going on).


#3

Im using script to run the code. Im using Windows 64. It opens the command prompt as usual. Yes I have it installed. Here’s the screen.


#4

There are three issues here.

  1. You need to use file extensions on all of your code files. Without them, the script package has no idea where to send the code (so it interprets your script as a batch script and tries to run it with cmd).

  2. script is incapable of handling files with spaces in their names (this applies to the whole file path). This is a flaw in how the package was written that creates a bug. From a software development perspective, the most optimal naming strategy is to use hyphens or underscores where you would use spaces to separate words (hyphens are more common in file names, whereas underscores are usually used for flag and configuration variable names). I believe that’s why it says that cmd isn’t found even though you obviously have it on your computer.

  3. You should not ever put a personal document inside a folder that contains an application, also for hygiene reasons. It might seem expedient, if you don’t code much, to store your code alongside the IDE you use, but if you do that you are guaranteed to run into a situation where Atom updates itself and destroys the app-1.34.0/ directory along with anything you have saved inside it. In the case where your operating system becomes compromised (which is only a matter of time with Windows even if you never contract any viruses), you may need to reinstall it, in which case you will lose the applications you have installed. It’s best to have all of your personal files in one of three places: in the designated folders in your user folder, in folders on your desktop (which is technically one of the above, but special), or in a separate drive from C:/ (physical or virtual doesn’t matter). Personally, I prefer the latter, but if you don’t have more than one hard drive and aren’t experienced with partitioning, don’t even try it unless you have a friend to help. The first two options are perfectly good unless (like me) you hate having things on the desktop and try to avoid doing things the native Windows way whenever possible. The drive alternative is optimal for cases where you might at some point decide to wipe Windows and install a different OS (which I do basically every time I get a new laptop and my old one still works).