Javac is not recognized on Windows 10

Contents

»Javac is not recognized as an internal or external command» is an error commonly encountered by people trying to compile Java programs on Windows using the command prompt. It can also be found when users try to check the current version of the main Java compiler.

error-message-5-11-2248001

What is JavaC?

Javac (pronounced “java-see”), is the main Java compiler included in the JDK (Java Development Kit) developed by Oracle Corporation. The compiler is designed to accept source code that conforms to the Java language specifications. (JL) and converts it to Java bytecode according to the Java Virtual Machine Specification (JVM).

What causes Javac to not be recognized as an error?

The error »Javac is not recognized as an internal or external command» occurs when the command prompt cannot find the Java PATH variable. This can happen for two reasons:

  • Java development kit is missing (JDK) in the machine: this usually occurs because the user mistakenly assumes that the Java compiler (javac) it is installed together with the Java runtime environment.

  • The path to Javac is not configured or is configured incorrectly: to compile from command prompt and make sure other application server tools work properly, the system needs to know the location of javac. If this is the case, you will need to set the path manually.

Paso 1: Install the Java Development Kit (JDK)

One of the main reasons this error occurs is that users who are just starting to learn Java are confusing the Java runtime environment (JRE) with the Java development kit (JDK).

The JRE is part of the JDK, but most of the time it is downloaded separately. Many programs that use Java Runtime include it in their installation packages.

Because there are very few reasons why you will need the Java Development Kit (JDK) if you are not interested in java development, you may have believed that Javac was already installed by the JRE, but the truth is that you will need to install all the Java development kit.

If you think this scenario is applicable to your situation, here is a quick guide to install the Java Development Kit (JDK) in order to resolve the error “javac is not recognized”:

  1. Visit this link (here) and click the download icon on Java Platform (JDK). This will ensure that you install the latest available version of the Java Development Kit. download-2-181-4284190Download the latest version of JDK

  2. On the next screen, scroll down to Java SE Development Kit and make sure to select the switch associated with the Accept License agreement. Then click on the download link associated with Windows. There are two options to choose from, but we recommend downloading the .exe file, as it will prevent you from extracting the content when the download is complete. download-jdk-8270564Download the Java Development Kit

  3. Once the download is complete, open the JDK installation executable and follow the on-screen instructions to complete the installation. java-tm-development-8756962Installing the Java Development Kit

  4. On the next screen, make sure both developer tools and source code are configured to install on your local hard drive along with all its sub-functions. What's more, if possible, We recommend that you keep the default installation path because the step 2 it would be easier. java-tm-choosing-8598229Install all components and subfeatures on your local hard drive

    Note: As an additional recommendation, make a note of the installation path in Install on, since you will need it in El Paso 2.

  5. Wait until the Java Development Kit is installed. When the process ends, restart your computer manually if not prompted automatically. the-java-development-kit-is-installing-1575611Installing the Java Development Kit

Now that you have made sure you have installed the correct package that installs JavaC, go to step 2 where we make sure we have correctly configured the path to JavaC.

Paso 2: set the Java environment variable and update the system path

Before starting this process, It is important to understand that the following procedures are only applicable if you have ensured that the Java Development Kit is installed correctly (paso 1).

If you have installed the JDK and you still get »Javac is not recognized as an internal or external command«, just ran into one of the most common technical problems faced by Java beginners. To finalize the Java Development Kit on Windows, you will need to perform a series of manual steps. These steps should always follow the JDK installation, even after updating java dev kit.

Here is a quick guide to setting the correct Java environment variable and updating the system path:

  1. Press the Windows key + R to open a Run dialog. Then type »sysdm.cpl» and hit Enter to open the System Properties window. system-properties-4-1809783Run dialog: sysdm.cpl

  2. Inside the System Properties window, go to Advanced tab and click Environment Variables. environment-variables-6-6371001Go to Advanced tab and click Environment Variables

  3. In the newly opened Environment Variable window, click the New button under System Variable. new-system-variable-6663669Add a new system variable

  4. In the New System Variable window, set variable name to JAVA_HOME and variable value to your JDK directory path. To save the changes, click ok. editing-java-variable-1760233Variable name and value settings

    Note: If you heard our advice in step 1 and noted the JDK installation path, you can paste it directly into the Variable Value.

    variable-8631112JDK install path

  5. Now that you are back in the Environment Variables window, look for a variable named path in System Variables. With the Path variable selected, click the Edit button. path-variable-5645679Select the path variable (in System variables) and click the Edit button

  6. In the Edit Environment Variable window, click the New button. new-button-9051549Click the New button

  7. Name the newly created environment variable % JAVA_HOME% bin and hit Enter. Later, press OK to apply the changes. java-home-bin-1841053Create a new environment variable and name it% JAVA_HOME% bin

  8. With this last step, you must configure your Java environment. Now you can compile applications from CMD or check your Javac version. javac-succesfull-3326580JavaC was configured correctly

There is an additional step you can take at the command prompt to make sure you have correctly set the path to your Java environment variable. Follow the steps below to see if your setup works:

  1. Press the Windows key + R to open the Run dialog. Then write “cmd” and hit Enter to open a command window. cmd-55-5996861Run dialog: cmd

  2. In the command window, type echo% JAVA_HOME% and hit Enter to see what return you get. If you see a printout with the JDK directory, then the step 2 was successful and your JAVAC works perfectly. In case you see a space instead of the JDK path, means you couldn't set environment variable; in this case, revisit El Paso 1 and El Paso 2. cmd-echo-2266011Checking if Java environment variable was set correctly

Subscribe to our Newsletter

We will not send you SPAM mail. We hate it as much as you.