Javac not recognized as internal or external command

by admin on August 17, 2013

Javac is the executable for compiling java applications.   When compiling a java program from command line, this is the most common issue people face.  Let’s see how we can fix this issue.

    1.  First thing we need to compile java programs is to have JDK(Java development Kit) installed on your computer.  If you are not sure whether you have already installed it or not, you can verify from appwiz.cpl.(More details here –  How do I check if Java is installed on my system)

Please note that having JRE is not enough to develop java applications. JRE only helps to run already built applications, we need JDK to compile Java code.

  1.  If java is installed, then you need to check if PATH environment variable points to the java executables directory.
    • Open command prompt
    • Run ‘set path’. This will print the current value of path environment variable. You can see the list of all the directories added. Check if  Java sdk path is added or not. If it’s added you should be able to see something like below.

      c:\>set path
      Path=C:\Program Files (x86)\Windows Resource Kits\Tools\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Quarantine\;C:\Program Files\Perforce;C:\Program Files\Microsoft Network Monitor 3\;c:\Program Files\Java\jdk1.7.0_17\bin

    • If you don’t find JDK path you can add now. Please note that the path you need to add on your system would vary based on the SDK version you installed and also the location of the installation. Check the folder “C:\Program Files\java”   and  “c:\Program Files (x86)\java” to find the exact path.
    • If you already have PATH set with the java location, check one more time if you have added path till the bin folder. So adding c:\Program Files\Java\jdk1.7.0_17 is not correct. You need to add c:\Program Files\Java\jdk1.7.0_17\bin.
    • You can modify PATH variable from command prompt or from GUI. For command line steps, please see  – Set path from windows command prompt
    • To modify PATH using GUI you can follow the steps below.

How to set JDK path

  1. Open System properties (Run sysdm.cpl)
  2. Go to Advanced tab
  3. Click ‘Environment variables’

  4. Under ‘System Variables’ scroll down to find PATH. Edit the entry and add JDK path.

  5. Click OK and close the windows.

Now open new command prompt and run ‘set path’, you can see that JDK path is added.  Note that if you run the command from a window which was opened before you modified the PATH variable, it would not print updated path. Even for compiling java programs, you need to open a new command window after setting PATH.

Additional Reading...

{ 31 comments… read them below or add one }

Shan August 26, 2013 at 6:48 am

I was getting this error “‘java’ is not recognized as an internal or external command..”. Thanks for the detailed information on how to fix this.

Reply

sruthi April 3, 2014 at 5:22 pm

This is really helpful to run java in my pc,, Thanks a lot for sharing this information..

Reply

Prognoey July 6, 2014 at 2:38 am

Thank you.Step by step teaching is very useful. I spent more than 2 hours to solve this problem and finally this forum help me. Thanks again.

Reply

dakota August 29, 2014 at 1:21 am

it still is popping up that error message for me? any idea whats wrong?

Reply

admin October 14, 2014 at 5:52 am

You need to open a new cmd window after setting the path.

Camille September 6, 2014 at 9:04 pm

worked for me. THANK YOU! look into the already existing Path variable and simply add the Java bin extension after a semi colon…

Reply

Mich October 14, 2014 at 5:25 am

Thanks! Done well. I just didn’t understand the procedure in the book but after reading your steps “clap, clap. clap” God bless! ^_^

Reply

Riko Takano November 13, 2014 at 1:47 am

Thank you so much sir :))

Reply

apurva December 18, 2014 at 5:40 pm

i have java installed on my computer i verified it.but when i type javac then it is showing above error even after setting path….what should i do?plz help

Reply

admin December 19, 2014 at 3:01 am

I am not sure if you have also verified JDK was installed and not just JRE. can you confirm this?
Also, did you open a new cmd after setting the path?

Devika January 20, 2015 at 7:13 pm

Hi

I have installed jdk 8 update 25,and also set the path and rebooted system.But still its showing message like java is not recognized as an internal /external command

Request your help

Thanks in advance

Reply

admin January 20, 2015 at 7:38 pm

Can you let us know the following to help you.
1)The path of the folder where your java bin folder is located.
2)The value of PATH environment variable(you can get using ‘set path’ command)

Reboot is not required to make PATH changes effective. Just a new cmd window should get new values.

Mehmet January 25, 2015 at 2:41 pm

Hı, after those steps, it compiled the java files but I get Could not find or load main class error .

Reply

needy February 18, 2015 at 5:54 pm

thanks a lot buddy.

Reply

mohammad March 18, 2015 at 7:30 am

Thank you…its Helpfull

Reply

Sabata April 1, 2015 at 10:24 am

Thanks a lot man..I can now compile java source file…you are the man…chess

Reply

Rhys April 12, 2015 at 4:23 pm

Here’s a weird one: My javac works just fine but -jar isn’t recognized. Path variable definitely contains my JDK path. What can I do?

Reply

admin May 9, 2015 at 5:48 am

Make sure you have jar.exe executable in the JDK path. This should have been installed by default in the same folder where javac.exe is present.

Alolita April 22, 2015 at 2:40 pm

Please I need your help, how to retrieve information after pressing deleting button? I deleted the “Path” and it’s value from the environment. Actually, I wanted to set the path for javac, I don’t know what information should I enter now into the path, but I have added the name of the jdk and it version to it, so now the path is lost together with the the values or whatever that was written in there before I edited it.

please, can anyone help me? please I need your help in how to solve the problem like this “javac not recognized as internal or external command”

your help is much appreciated!

Thank you!

Reply

admin April 23, 2015 at 4:42 pm

You can set it again, that should not be a problem. The value I have on my system is this.

C:\>set path
Path=C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Windows Resource Kits\Tools\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.
0\;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Quarantine\
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

From the above, you can remove the folders not existing on your system and set PATH accordingly.

Bryan April 29, 2015 at 12:56 pm

I have installed jdk 8 update 45, and set the system environment path. I made sure that my command prompt window was closed and then open the command prompt window and I still getting the ‘javac’ is not recognized as an internal /external command.

1)The path of the folder where your java bin folder is located.
C:\Program Files\Java\jdk1.8.0_45
The patch C:\Program Files\Java has the following folders
jkd1.8.0_45
jre1.8.0_31
jre1.8.0_45

2)The value of PATH environment variable(you can get using ‘set path’ command)
C:\ProgramData\Oracle\Java\javapath;c:\Program Files (x86)\AMD APP\bin\x86_64;c:\Program Files (x86)\AMD APP\bin\x86;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Java\jdk1.8.0_45

Thanks in advance

Reply

admin April 29, 2015 at 6:57 pm

there’s minor error in the java path you were using. You need to add C:\Program Files\Java\jdk1.8.0_45\bin. bin was missing in the path you have.

jeanc May 22, 2015 at 4:49 pm

Thanks a lot. it worked

Reply

Matt June 3, 2015 at 8:57 pm

I’ve read through your guide and the comments and am still having an issue. Any help would be vastly appreciated; I’ve put hours into this already.

1) PATH : “C:\Program Files\Java\jdk1.8.0_45\bin”
PATHEXT: “.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC”

2) I have closed and reopened cmd.

Reply

admin June 3, 2015 at 9:28 pm

Let us know output of this dir "C:\Program Files\Java\jdk1.8.0_45\bin"
PATH seem to have been set correctly. But I doubt if you have java*.exe files in the folder or not.

Aryan June 15, 2015 at 9:41 am

Thankx , I was getting this error from the last 2 months and now finally i have resolved it……:-)

Reply

rohan June 19, 2015 at 4:25 pm

after following all the above steps, i am able to complile and run succesfully all the codes that are saved in my bin folder.

but if i save my .java files in some other folder, and try to compile them, then i got the ”javac is not recognized as intrnl or extrnl comnd..” error.

what should i do to run my codes from any folder?

Reply

admin June 19, 2015 at 9:53 pm

Looks like you did not set value in PATH/did not set the right value. Please see the instructions above for setting PATH correctly.

Anna June 24, 2015 at 5:29 pm

Hi. It still won’t work for me, is says Javac not recognized as internal or external command still.. I’ve reopended the cmd-window and don’t know what’s wrong. I thought I could answer the same questions someone else got, maybe you could see whats wrong or have another idea of what I can do.

1)The path of the folder where your java bin folder is located.
C:\Program Files (x86)\Java\jdk1.8.0_40\bin
The patch C:\Program Files (x86)\Java has the following folders
jdk1.8.0_40
jre1.8.0_40
jre1.8.0_45

2)The value of PATH environment variable(you can get using ‘set path’ command)
Path=C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\C:\Program Files\ThinkPad\Bluetooth Software\;C:\Program Files\ThinkPad\Bluetooth Software\syswow64;C:\Program Files (x86)\Java\jdk1.8.0_40\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

Reply

admin June 24, 2015 at 11:21 pm

Can you check if you have javac file in the bin folder. Though it’s unlikely that the file won’t be present, but I don’t see any other reason why you still get the error.

Lakshith June 27, 2015 at 6:18 am

Thank you very much for the instructions. I fixed that recognizing error.

Reply

Leave a Comment

Previous post:

Next post: