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

29.3K    Asked by ShantellRoye in Devops , Asked on Jul 26, 2021

 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

Answered by Fiona Dickens

javac is not recognized as an internal or external command, is an error that occurs while we compile the Java application. It is because the JVM is unable to find the javac.exe file. The javac.exe file is located in the bin folder of the JDK. The reason behind to occur the error is that the PATH is not added to the System's environment variable.

Check your javac path on Windows using Windows Explorer C:Program FilesJavajdk1.7.0_02in and copy the address.

Go to Control Panel. Environment Variables and Insert the address at the beginning of var. The path followed by a semicolon. i.e C:Program FilesJavajdk1.7.0_02in; . Do not delete the path existent, just click in and go to the left end and paste the line above. Do not try anything else, because you just need to link your code to "javac.exe" and you just need to locate it.

Close your command prompt and reopen it, and write the code for compilation and execution.



Your Answer

Answers (4)

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.

7 Months

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

7 Months

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

7 Months

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

7 Months

Interviews

Parent Categories