Java throws the error, ‘javac’ is not recognized as an internal or external command, operable program or batch file, if the path of JDK is not set in environment variable.

According to Java documentation

Note: The PATH environment variable is a series of directories separated by semicolons (;) and is not case-sensitive. Microsoft Windows looks for programs in the PATH directories in order, from left to right.

You should only have one bin directory for a JDK in the path at a time. Those following the first instance are ignored.

To add JDK path to the environment variable, follow these instructions –

Check where JDK is installed in your system. The default location is –

C:\Program Files\Java\jdk-{version}

Note: There are 2 things – JDK and JRE. javac is the part of JDK and not JRE. If you do not find a directory with name jdk in your Java installation path, then it means JDK is not installed correctly. You need to run installation again.

  • Open Control Panel > System
  • Click on Advanced > Environment Variables
  • Add bin location (C:\Program Files\Java\jdk-15\bin) to the PATH variable.

Or, if you do not want to add path variable, you can still use javac using full path –

C:\> "C:\Program Files\Java\jdk-15\bin\javac" MyClass.java

    Tweet this to help others

This will solve your error of, javac not recognized as internal/external command.

Comments

About the Author

akamit

I am Akash Mittal, an overall computer scientist. If you want to guest post, need help in your projects, want to advertise, Feel free to contact me at [email protected]

View All Articles