How to Fix Javac Is Not Recognized as an Internal or External Command, Operable Program or Batch File
-
Javac
in Java -
'javac' is not recognized as an internal or external command, operable program or batch file
-
Causes of
'javac' is not recognized as an internal or external command, operable program or batch file
-
Solution to
'javac' is not recognized as an internal or external command, operable program or batch file
This article shows the possible causes of Java’s 'javac' is not recognized as an internal or external command, operable program or batch file
and the possible solutions to this error. To start, let’s look at what javac
is.
Javac
in Java
Javac
is the primary Java compiler included in the JDK
(Java Development Kit) that Oracle Corporation developed. The name javac
is pronounced as java-see
.
The source code must comply with the JLs
(Java Language standards) for the compiler to accept. The compiler then transforms the source code into Java bytecode compatible with the JVMs
(Java Virtual Machine Specification).
Environment Variables
A key-value pair such as windir=C:WINDOWS
is an environment variable. Most of them were packaged together with the operating system, and some are necessary for the device to operate in its intended manner.
When any program including cmd
is started, a list of them is supplied to it as an argument. Windows provides users with two environment variable options.
- User environment variables
- System environment variables
'javac' is not recognized as an internal or external command, operable program or batch file
This standard error occurs in the Windows command line when you type a command not present in the System PATH
. In this case, the error occurs because the javac
command, which is used to compile Java source files and create class files, is not present in the PATH
.
The best approach to check this is to use the following command.
echo % PATH %
You have access to the included bin directory when you can locate your JDK
installation folder or JAVA HOME
in the PATH
environment variable. This directory contains all java
binaries, such as javac
and java
commands, which are required to compile and run Java programs.
If that’s the case, you must add the JDK
folder’s bin
folder to your PATH
. It may be that your PATH
doesn’t contain the JDK
or bin
directory.
Causes of 'javac' is not recognized as an internal or external command, operable program or batch file
This error occurs when the Command Prompt cannot locate the Java PATH
variable in its current working environment. The following are some of the possible reasons for this.
-
JDK
(Java Development Kit) is not on the system. This generally occurs due to the user’s false assumption that the Java Compiler (javac
) is installed together with theJRE
(Java Runtime Environment). -
It appears that the path to
javac
has not been specified or that it has been set incorrectly. The system must be aware of the location ofjavac
to compile code using the Command Prompt and to ensure that other application server utilities operate as expected.In this scenario, you will have to set the location manually.
- Setting
PATH
with an incorrect directory is another potential error cause. For example, the path might be missing a forward slash or contain something else entirely.
Solution to 'javac' is not recognized as an internal or external command, operable program or batch file
Let’s solve this issue so that the Java program can be compiled and launched from the command line.
- To bring up the command prompt on Windows, click the
Start
button, select theRun
window, typesysdm.cpl
and click onOK
to openSystem Properties
. - Navigate to the
Advanced
tab of theSystem Properties
window, and then click on theEnvironment Variables
. - Click the
New
button under theSystem variable
heading in theEnvironment Variables
window that has just popped up. - In the
New System Variable
window, give the variableJAVA_HOME
as its name and specify the path to the directory that contains yourJDK
software as its value. Simply clicking theOK
button will save the changes. - Once we’ve navigated back to the
Environment Variables
window, search for a variable namedpath
located under theSystem variables
heading. Click theEdit
button while selecting thePath
variable. - To create a new environment variable, use the
New
button in theEdit
window for the variable. - After creating the new environment variable, give it the name
%JAVA_HOME%\bin
and press the Enter key. After that, click on theOK
. - The Java environment will be configured after this step. Applications will be able to be compiled from the command prompt.
Ensure the Java environment variable path is configured and ready to use. Checking to determine if your configuration is correctly functioning can be done by following the steps below.
- To open the command prompt on Windows, click the
Start
button, select theRun
window, typecmd
, and click onOK
. - In the window, type
echo %JAVA_HOME%
and then press Enter to find out which result you receive. If there is a print with the directory to theJDK
, you may rest assured thatJAVAC
is running correctly.
I have been working as a Flutter app developer for a year now. Firebase and SQLite have been crucial in the development of my android apps. I have experience with C#, Windows Form Based C#, C, Java, PHP on WampServer, and HTML/CSS on MYSQL, and I have authored articles on their theory and issue solving. I'm a senior in an undergraduate program for a bachelor's degree in Information Technology.
LinkedInRelated Article - Java Error
- How to Fix the Error: Failed to Create the Java Virtual Machine
- How to Fix the Missing Server JVM Error in Java
- How to Fix the 'No Java Virtual Machine Was Found' Error in Eclipse
- How to Fix Javax.Net.SSL.SSLHandShakeException: Remote Host Closed Connection During Handshake
- How to Fix the Error: Failed to Create the Java Virtual Machine
- How to Fix Java.Lang.VerifyError: Bad Type on Operand Stack