English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

How to solve the problem that javac is not recognized as an internal or external command in Java?

If you see this error when compiling the program, it indicates that you have not installed Java correctly in the system, or you have not set the Path variable.

Path variable-The path environment variable is used to specify a set of directories that contain executable programs.

When you try to run a program from the command line, the operating system will directly search for the specified program in the current directory (if any) and then execute the program.

If the program is not available in the current directory, the operating system will“ PATH”Verify the directories specified in the environment variables.

Set the path for Windows

Assuming you have already installed Java in the c:\ Program Files \ java \ jdk directory-

  • Right-click 'My Computer' and select 'Properties'.

  • Click the 'Environment Variables' button under the 'Advanced' tab.

  • Now, change the 'Path' variable so that it also includes the path to the Java executable files. For example, if the path is currently set to 'C:\ WINDOWS \ SYSTEM32If the path is set to 'C:\ WINDOWS \ SYSTEM', then change the path to 'C:\ WINDOWS \ SYSTEM32; c:\ Program Files \ java \ jdk \ bin.

Set the path for Linux, UNIX, Solaris, and FreeBSD

The environment variable PATH should be set to point to the installation location of the Java binary file. If you encounter difficulties while performing this operation, please refer to your shell documentation.

For example, if bash is used as the shell, the following line should be added at the end of '.bashrc': export PATH = / path / to / java: $PATH'