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

+9 votes

Announcement! Career Guide 2019 is out now. Explore careers to become a Big Data Developer or Architect!

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:\Users\Ivy>cd \
C:\cd java files
C:\java files>set path=C:Program Files (x86)\Java\jdk1.7.0\bin
C:\java files>javac Hello.java
'javac' is not recognized as an internal or external command, operable program or batch file
May 23, 2018 in Java by Parth
• 4,640 points
216,388 views
Thanks it worked
How can I solve this problem!!!
thanks that really working.

14 answers to this question.

+7 votes
  • Check your javac path on Windows using Windows Explorer C:\Program Files\Java\jdk1.7.0_02\bin and copy the address.

  • Go to Control Panel. Environment Variables and Insert the address at the beginning of var. Path followed by semicolon. i.e C:\Program Files\Java\jdk1.7.0_02\bin; . 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 compile and execution.

answered May 23, 2018 by Rishabh
• 3,580 points
how can i get back the existing path?
Sir agar galti se paths jo already sets hai woh delete Ho jay to Kay kare kuki mere ko existing paths hai woh delete Ho Gaye hai ab textpad error de raha hai

For windows system you can follow the below steps.

  • From the start menu, open Run.
  • Type regedit
    • Find HKEY_LOCAL_MACHINE folder
    • Go to the SYSTEM folder
    • Go to the ControlSet002 folder
    • Go to Control folder
    • Go to Session Manager
    • Go to Environment folder
    • Then, inside Environment folder, double click Path

The previous Path should be there.

Thank you. It works.
Thanks a lot. Its working.
+4 votes

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.

Add Path variable and you are good to go.

answered Nov 13, 2018 by Nabarupa
I am incredibly new to Java, what is the path?
Hello @User, Path is an environment variable used to access the java binaries like java or javac that are used to run java programs and compile java source files. Path can be overridden by Java Settings. Path is used by operating system to find any binary or command typed in shell.

Command used to set Path:-

set PATH=%PATH%;C:\Program Files\Java\JDK1.6.20\bin

Hey there! When you install java, you will require the commands like java and javac to work form your command prompt. But the command prompt will not know what these commands are and so the command prompt displays that these commands are not found. To let the command prompt run these commands, we have to mention the location of the files that will run these commands. This location is set under environment variable and is known as a Path.

I had tried doing all the stuff like coping the location of the bin file C:\Program Files\Java\jdk1.8.0_251\bin and pasting it in Path  in the environment variables and again opening the command prompt but then also the problem arises is there any other solution to this and i had also tried deleting and reinstalling the java from my windows 7
Hi, @Taufique

Kindly check if the directory in which you have saved your program and directory of cmd is same or not.
thankyou so much sir.
+6 votes

Try this it works fine :

C:\ YourFolder >set path=C:\Program Files\Java\jdk1.7.0_09\bin;
C:\ YourFolder >javac YourCode.java
answered Nov 13, 2018 by Jino
• 5,770 points
work fine but not show path of java and ant in

environment variable
thank you so much it worked
dude i've created an account here to specifically thank you. THANKS A FUCKING TON MY DUDE
this really worked while the above one couldnt...thankyou so much:)
Thank you so much for your help Jino
thanks a lot dude:)
It says access is denied, how can i fix that?
Hey, @There,

Can you please provide a little bit more information what exactly does the exception being thrown?
It works! Thank you so much!
Thanks a lot!
+4 votes

You need to add JAVA_HOME/bin folder in your machine's PATH to solve this error.

You can refer this article to see how to do it: http://www.java67.com/2015/07/javac-is-not-recognized-as-internal-or-external-command-program-batch-file.html#ixzz5WjtBMio9

answered Nov 13, 2018 by Ravi
thank you so much <3
+4 votes

Set the Java path to the following:

set path=C:\Program Files (x86)\Java\jdk1.8.0_171\bin

This should solve the error.

Note: Replace the version with the version installed in your system

answered Nov 13, 2018 by Khushi
+2 votes

Make sure of these things when you face such errors:

  1. Find the Java path; it looks like this: C:\Program Files\Java\jdkxxxx\bin\
  2. Start-menu search for "environment variable" to open the options dialog.
  3. Examine PATH. Remove old Java paths.
  4. Add the new Java path to PATH.
  5. Edit JAVA_HOME.
  6. Close and re-open console/IDE.
answered Nov 13, 2018 by Hannah
• 18,420 points
+2 votes

You mistyped the set command – you missed the backslash after C:. It should be:

C:\>set path=C:\Program Files (x86)\Java\jdk1.7.0\bin
answered Nov 13, 2018 by Maverick
• 10,820 points
+1 vote

Follow the following steps:

  1. Open Control Pannel
  2. Open System and Security
  3. Open System
  4. Go to Advanced System Settings
  5. Click on Environment Variables
  6. Open PATH
  7. Add you Java Path like this:
C:\Program Files\Java\jdk1.8.0_172\bin

If there are already a path mentioned there just add a semi colon before this

;C:\Program Files\Java\jdk1.8.0_172\bin

Open Command Prompt 

Type javac, enter.

All set. 

You have successfully added the environment variable.

answered Nov 27, 2018 by Shuvodip Ghosh
Thank you! worked like a charm
Hi! I hope you are doing good. Please do register at Edureka Community and upvote this answer if it has helped you.

Thanks
Tqqq it worked.
+1 vote
Just add the path to your environment variable and you are good to go.
answered Nov 27, 2018 by Stefany
+1 vote

I think all these answers will help you clear this error. Let me point out the reason behind this error. This 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. 

answered Nov 27, 2018 by Kailash
+1 vote
  • Check your javac path on Windows using Windows Explorer C:\Program Files\Java\jdk1.7.0_02\bin and copy the address.

  • Go to Control Panel. Environment Variables and Insert the address at the beginning of var. Path followed by semicolon. i.e C:\Program Files\Java\jdk1.7.0_02\bin;

answered Feb 8, 2019 by rajesh
• 1,230 points
Thanks. it was very helpful
+1 vote

put    ;  at end of the statement

answered Jan 8 by anonymous
0 votes
Open cmd prompt :
Step1: type just word path
Then you will see path
Step2: type path= (here you want to type the path with out this bracket )

Like: path=C:\Program Files\Java\jdk1.8.0_241\bin
Step 3: type javac to check its ready
answered Mar 27 by AshikMB
Thanks man,

This relly works
0 votes

This error occurs usually when you try to compile a Java source file using javac command e.g. javac Helloworld.java and your PATH is not set properly. It means that javac.exe executable file, which exists in the bin directory of the JDK installation folder is not added to the PATH environment variable. In order to solve this error, you need to add JAVA_HOME/bin folder in your machine's PATH. Until your add Java into your system's PATH variable, you cannot compile and run Java program.

Just follow the steps given below to resolve your problem:

1) Just click on the Start button and open the command prompt and then type cmd on the run window.

2)  Type echo %PATH%,  it will now show you all the directories available in the PATH environment variable. The PATH output that you will receive, just copy it into your text editor e.g. Notepad or Word-pad and search if it contains the JDK installation directory or JAVA_HOME. Just take an example: Suppose if your JDK is installed on "c:\program files\java\jdk1.8.0", then PATH must 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 the bin directory.  Sometimes you may also see something 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 the following command

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

This is also called setting PATH in Java. Once PATH is set you can compile, run and monitor Java programs by using various tools that come with JDK installation.

4) Now, just run the javac command again and do not forget to close the current command prompt.  Any change in the environment variable is only available to new cmd windows.

answered Aug 28 by Pistle
• 1,000 points

Related Questions In Java

0 votes
1 answer

'javac' is not recognized as an internal or external command, operable program or batch file.

Hey @Paridhi, check this out https://www.edureka.co/community/4800/unable-resolve-error-recognized-internal-external-command This should solve ...READ MORE

answered Apr 19 in Java by Sirajul
• 58,130 points
417 views
0 votes
2 answers

When I am running eclispe on my computer it is throwing error. How to resolve it?

If you have downloaded the 64 bit ...READ MORE

answered Dec 10, 2018 in Java by Sushmita
• 6,890 points
256 views
0 votes
1 answer

Error:Unable to execute dex: Multiple dex files define

Hello @kartik, The Solution for me was just ...READ MORE

answered May 25 in Java by Niroj
• 68,100 points
175 views
0 votes
2 answers

What is a StackOverflow Error

stackoverflow error – StackOverflow Error in Java. This error is thrown to ...READ MORE

answered Aug 28 in Java by Pistle
• 1,000 points
337 views
+1 vote
2 answers
0 votes
1 answer

How to resolve the error: could not find or load main class?

If you are getting error: could not ...READ MORE

answered May 28, 2018 in Java by Parth
• 4,640 points
3,316 views
0 votes
3 answers

How to check whether a string is empty or not? Is there a function for this?

str != null && str.length() != 0 alternatively str ...READ MORE

answered Sep 11, 2018 in Java by Sushmita
• 6,890 points
248 views
+1 vote
2 answers

Is there a code to find 64-bit JVM or 32-bit JVM (from within a program)?

Do I need to understand the difference ...READ MORE

answered Jun 11, 2019 in Java by Jim
• 810 points
809 views