'javac' is not recognized as an internal or external command

'javac' is not recognized as an internal or external command, operable program or batch file error comes when you try to compile a Java source file using javac command e.g. javac Helloworld.java but your PATH is not set properly. It means that javac.exe executable file, which exists in bin directory of JDK installation folder is not added to PATH environment variable. You need to add JAVA_HOME/bin folder in your machine's PATH to solve this error. You cannot compile and run Java program until your add Java into your system's PATH variable. Here is how this error looks like in command prompt of windows machine :

'javac' is not recognized as an internal or external command error windows

Steps to fix 'javac' is not recognized as an internal or external command :

Let's see how to fix this problem to compile and run Java program from command line :

1) Open command prompt in Windows by clicking Start button and then typing cmd on run window, as shown in following screenshot :

How to open command prompt in windows

2) Type echo %PATH%,  it will now show you all the directories which are available in PATH environment variable. Now copy this PATH output into your text editor e.g. Notepad or Word-pad and search if it contains the JDK installation directory or JAVA_HOME. For example, if your JDK is installed on "c:\program files\java\jdk1.8.0", then PATH should include "c:\program files\java\jdk1.8.0\bin". It's important to include bin directory because all executable required to compile, run and debug Java program are stored in bin directory.  Sometime you will also see like %JAVA_HOME%\bin , where JAVA_HOME is another user defined environment which points to Java installation directory. 

3) If PATH doesn't contain bin directory of JDK, then you can add them into PATH by following command

set PATH = %PATH%;"c:\program files\java\jdk1.8.0\bin

This is also known as setting PATH in Java. Once PATH is set you can compile, run and monitor Java programs by using various tools which comes with JDK installation. If you are not very familiar with setting environment variable from command prompt, you can also use settings window as shown in this article.

4) Don't forget to close the current command prompt and open a new one before running the javac command again.  Any change in environment variable is only available to new cmd windows.

That's all about how to fix 'javac' is not recognized as an internal or external command, operable program or batch file error in Windows. You might get similar error e.g. 'java' is not recognized as an internal or external command, operable program or batch file, if you try to run an already compiled Java program and PATH is not set in your machine.

Further Learning
Complete Java Masterclass
Java Fundamentals: The Java Language
Java In-Depth: Become a Complete Java Engineer!


  1. Hey Guys,
    Even I was having the same issue and I did following 2 things which finally worked for me:
    1. In system variables (in Advanced tab) created a new variable 'CLASSPATH' with value 'C:\Program Files\Java\jre-10\lib'
    2. Closed current cmd prompt window (as it was still giving the same error), opened new cmd window where I got correct response for javac :)
    Hope it helps.

    1. Thanks, it was "the" exact case.

    2. Thank You, It worked for me

    3. finally thank you

    4. still broken...

      Is it because one of my other programs had a variable called path? Anyway I removed that program but its still busted.

    5. just install jdk 8. can't run programs at jdk 9 up

  2. Thanks, Its Working

  3. I use this very steps and used to work.. But now its not working..
    What to do? Plzz help

    1. Hello Unknown, can you please provide more details, what are you trying to do, what is your system, what is in your PATH environment variable etc?

  4. Working by setting c:\program files\java\jdk1.8.0\bin as 'path' in user variables(Y)

  5. Thanks. Its working for me by setting c:\program files\java\jdk1.8.0\bin as 'PATH' in user variables(Y).

  6. Replies
    1. Can you please provide some more details? what error you are getting, what is in your PATH and CLASSPATH? What have you tried so far? This will help me to understand the issue better and help you faster.

    2. Tried path, tried class path and path.
      Path = C:\Program Files\Java\jdk-12.0.1\bin

      Windows 7 64 bit operation system.
      I have installed java 5 times now, 0 have worked. Followed 5 completely different tutorials, 0 worked.

      Error is javac is not recognized as internal or external command program batch file.html (read the title...)

      Does it have to be called PATH or CLASS PATH or what.

      I recently had a broken called brakets that had a path file so I deleted it, probably makes no effect I don't know.

      My PC isn't very good, does that make a different. I don't know, it can run other things, e.g. unity.

      Is that enough info?

    3. can you open a command prompt and run the echo %PATH% for me and print the output here?

    4. C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\bose-3\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft Emulator Manager\1.0\;C:\Program Files (x86)\Microsoft Team Foundation Server 2015 Power Tools\;C:\Android;C:\Windows\System32;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files\nodejs\;C:\Program Files (x86)\WebEx\Productivity Tools;C:\Program Files (x86)\Microsoft Team Foundation Server 2012 Power Tools\Best Practices Analyzer\;C:\Program Files (x86)\Webex\Webex\Applications;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Java\jre1.8.0_161\bin

  7. 0001011110111101111111011011101011110111111110001010101011111110010101000101000010101010101010101010101010101000101111110101010001000111010101010101010101010101010100000000000000000001111010101011010111010101010101010110

  8. When the file is placed at bin location, there is no error in compilation. But when I tried to compile the file at desktop location, I'm facing issues. Can you help me?

    1. check if your PATH has desktop in it, I think it has bin folder but not Desktop.

    2. Thanks... Now it's working fine...

  9. I did the same thing but it is showing like that can any one help me

  10. C:\Program Files\Java\jdk-12.0.2\bin
    im getting error msg 'Hello.java' is not recognized as an internal or external command,
    operable program or batch file.