0% found this document useful (0 votes)
16 views

Resolving Javac Not Working

Uploaded by

ntandogift63
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Resolving Javac Not Working

Uploaded by

ntandogift63
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Resolving "javac is not recognized" Error in Java Compilation

This document outlines the steps to fix the error "javac is not recognized as an internal
or external command" you encounter when compiling Java code.

Understanding the Error:

This error arises when your command prompt (or terminal) cannot locate the javac
compiler, a crucial tool for compiling Java source code. Two primary reasons can
cause this:

1. Missing JDK Installation: The Java Development Kit (JDK) provides javac within
its bin directory. If the JDK is not installed, javac is unavailable.
2. Incorrect Path Configuration: Even with a JDK installation, the command
prompt might struggle to find javac if the path to the JDK's bin directory isn't set
in your system's environment variables.

Resolving the Issue:

Follow these steps to rectify the error:

1. Check if Java Development Kit (JDK) is installed:

Open a new command prompt or terminal window.

Type java -version and press Enter.


If the JDK is installed, you should see the Java version information displayed. Go to
step 2.

If you get the error: ‘java’ is not recognized as an internal or external command,

Install the Java Development Kit (JDK):

• Download the latest JDK from the official Oracle


website: https://www.oracle.com/java/technologies/downloads/
• Follow the installation instructions for your operating system (Windows).

2. Set the PATH Environment Variable (if JDK is already installed):

Windows:

• Open explorer.

• Right-click on "This PC" (or "My Computer") and select "Properties."


• Go to "Advanced system settings" and then click on "Environment Variables."

• Under "System variables," find the variable named "Path" and click "Edit."

• Check if the path to your JDK's bin directory is showing. Something like this:
C:\Program Files\Java\jdk21.0.2\bin

There’s nothing about java or jdk.


• If missing add it. Copy the path where your JDK is installed. Usually
in C:\Program Files\Java\jdkX.Y.Z.
• Add the path ;C:\Program Files\Java\jdk21.0.2\bin (remember the semicolon at
the beginning if other paths exist).

• Click "OK" on all open windows to save the changes.

3. Verify the Changes:

• Open a new command prompt or terminal window.


• Type java -version and press Enter. If the JDK is installed and the path is set
correctly, you should see the Java version information displayed.
• Now try typing javac and press Enter. The error message should be gone.

You might also like