Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Devops
  3. Question
Devops

Unable to resolve this error javac is not recognized as an internal or external command

Asked by Shantell Roye Jul 26, 2021 31.9K views 5 answers
Share

About this question

 I am new to Java application and having trouble compiling a simple Helloworld program. JDK 1.7.0 is installed in my Windows 7 and was able to set the path variable but didn't work. I keep getting the following error:

C:UsersIvy>cd 
C:cd java files
C:java files>set path=C:Program Files (x86)Javajdk1.7.0bin
C:java files>javac Hello.java
'javac' is not recognized as an internal or external command, operable program or batch file

Your answer

5 Answers

Ranjana Admin JanBask Expert Latest answer

Answered on May 23, 2024

The error "javac is not recognized as an internal or external command" typically indicates that the Java Development Kit (JDK) is not properly installed, or its bin directory is not added to the system's PATH environment variable. Here’s a step-by-step guide to resolve this issue on a Windows system:


Step 1: Install the JDK

Download the JDK:

  • Go to the Oracle JDK download page or the OpenJDK download page.
  • Download the appropriate installer for your operating system.

Install the JDK:

Run the installer and follow the on-screen instructions.

By default, the JDK is installed in C:Program FilesJavajdk-.

Step 2: Add JDK to the System PATH

Open Environment Variables:

  • Right-click on This PC or Computer on your desktop or in File Explorer.
  • Select Properties.
  • Click on Advanced system settings on the left.
  • Click the Environment Variables button at the bottom.
  • Find and Edit the PATH Variable:

In the System variables section, scroll down and find the Path variable. Select it and click Edit.

Add the JDK bin Directory to PATH:

In the Edit Environment Variable dialog, click New and add the path to the JDK bin directory. For example: C:Program FilesJavajdk-in.

Save and Apply:

  • Click OK to close the Edit Environment Variable dialog.
  • Click OK to close the Environment Variables dialog.
  • Click OK to close the System Properties dialog.

Step 3: Verify the Installation

Open Command Prompt:

  • Press Win + R, type cmd, and press Enter.
  • Check the Java Compiler:
  • Type javac -version and press Enter.

You should see the version of the javac compiler printed to the console. If you see the version, the setup is complete and the error should be resolved.

Additional Troubleshooting

If you still encounter issues, consider the following:

  • Ensure Correct JDK Path: Double-check that the path you added to the PATH variable is correct and points to the bin directory of the JDK installation.
  • System Restart: Sometimes, a system restart is required for the changes to take effect.
  • Multiple Java Versions: If you have multiple versions of Java installed, ensure the PATH variable points to the desired version's bin directory.
  • By following these steps, you should be able to resolve the "javac is not recognized as an internal or external command" error and successfully compile Java programs.

Was this helpful?

Mnop

Answered on May 18, 2024

You can find the steps here - https://getlearntech.com/fix-for-javac-is-not-recognized-as-an-internal/

Was this helpful?

Mnop

Answered on May 18, 2024

You can find the steps here - https://getlearntech.com/fix-for-javac-is-not-recognized-as-an-internal/

Was this helpful?

Mnop

Answered on May 18, 2024

You can find the steps here - https://getlearntech.com/fix-for-javac-is-not-recognized-as-an-internal/

Was this helpful?

More Devops discussions