Javac is not recognized as an internal or external command is an error received by many newbie programmers when they try to compile a program. In fact, this error has more to do with the general understanding of command line interface (CLI) than Java programming. Let us devote a few lines to understand the command line interface.
When you open a command line and type a command, you are actually running a program stored somewhere on your disk. In Windows, open the command prompt; by default, you will see the path C:\users\YourUserName in the command prompt window. Now, type “calc” without quotes and Windows will instantly open the calculator. Actually, calc is a program stored in the following location on your disk.
C:\Windows\System32
You do not need to navigate to the System32 folder to run this program because Windows runs all the programs stored in System32 folder regardless of your current folder location.
However, Windows will not run programs stored in any folder on your disk unless you navigate to that folder. This is the reason you see the error Javac is not recognized as an internal or external command.
The javac.exe is copied, when you install Java development kit (JDK). Usually, the javac program file is located in C:\Program Files\Java\jdk_version_number\bin. To run the javac program, you need either to go to the folder where javac.exe is located, or add the path to Windows environment variables.
When you install JDK, it also adds the path of javac to environment variables. However, if you are receiving this error, it means that JDK was unable to add this path to environment variables. To add the path manually, go to the Windows Control Panel, System, and click Advanced system settings. On the Advanced tab, click Environment Variables. Click New under system variables and copy-paste the path of the folder where the javac.exe file is located.
I’m Kelly Hood! I blog about tech, how to use it, and what you should know. I love spending time with my family and sharing stories of the day with them.