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
463,277 views
Thanks it worked
How can I solve this problem!!!
thanks that really working.
thank you so much for the help.

16 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,620 points
What happens if the existing path is being deleted?
Hello @User, nothing will happen. When you try to execute the java program you won't find the path.

Rishabh -- thanks for your answer -- it worked!!  Just for clarity to any newbie readers like myself: it wasn't clear that the variable name is Path, that it already exists (for my case) and it requires clicking on Edit  and adding an additional value to it.  Alright, thanks again Rishabh!!

@mchez I agree with your concern, but Rishabh's answer is quite helpful.
Brother, what to do if it still shows the same error as before.

if you know please tell.

thanks,
Hey, @ Aditya,

Could you please clarify what you are trying to do and what exact error you are getting?
unfortunately , I deleted the existent path . what to do in this case
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.
Thanks It's worked
+5 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.
how to add it plzz help
Hi, @Naveen,

Do you want to add the JDK installation folder to the PATH environment? If you go through the above comments it is mentioned in @Nabarupa's comment.
+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,820 points
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!
thank u jino
+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 14, 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 14, 2018 by Hannah
• 18,540 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 14, 2018 by Maverick
• 10,840 points
+2 votes

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,270 points
Thanks. it was very helpful
+1 vote

put    ;  at end of the statement

answered Jan 8, 2020 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, 2020 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 29, 2020 by Pistle
• 1,000 points
0 votes

Hey techies,

Even I have faced the same issue and came up with the solution given below:

For experienced readers:

  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 the PATH. Remove old Java paths.
  4. Add the new Java path to PATH.
  5. Edit JAVA_HOME.
  6. Close and re-open console/IDE.

You have encountered one of the most notorious technical issues facing Java beginners: the 'xyz' is not recognized as an internal or external command... error message.

In a nutshell, you have not installed Java correctly. Finalizing the installation of Java on Windows requires some manual steps. You must always perform these steps after installing Java, including after upgrading the JDK.

answered Dec 10, 2020 by Gitika
• 65,890 points
0 votes

Hey, all 

One important thing I guess everyone will focus that once we encounter any error, let's get into the fact that why did we encounter that or what that error means!

let's have a look here!

It means that the javac.exe executable file, which exists in the bin directory of the JDK installation folder is not added to a PATH environment variable. You need to add the JAVA_HOME/bin folder in your machine's PATH to solve this error. You cannot compile and run a Java program until your add Java into your system's PATH variable.

Why The “not recognized as an internal command” Error Occurs

  1. Other Apps Messing Up Your System.
  2. Not Having The Program Installed On Your Computer.
  3. Ensure The Program Actually Exists On Your PC.
  4. Use The Full Path To The Executable File.
  5. Enclose The File Path With Double Quotes.
  6. Move The File To System32 Folder.
answered Dec 10, 2020 by Rajiv
• 8,910 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 20, 2020 in Java by Sirajul
• 59,230 points
1,759 views
0 votes
1 answer

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

 While I was solving this problem, the ...READ MORE

answered Feb 17, 2022 in Java by Aditya
• 7,680 points
1,242 views
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
11,395 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, 2020 in Java by Niroj
• 82,880 points
1,892 views
0 votes
0 answers

Javac file not found error.

I'm completely new to java. I spent ...READ MORE

Nov 21, 2021 in Java by anonymous
• 120 points
610 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 29, 2020 in Java by Pistle
• 1,000 points
2,121 views
+1 vote
2 answers
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,920 points
1,389 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
2,269 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP