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

+8 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,630 points
147,409 views
Thanks it worked
How can I solve this problem!!!

13 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
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.
+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.
+5 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,660 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!
+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
+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,060 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
+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

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
• 54,070 points
216 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
189 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
• 32,990 points
43 views
0 votes
1 answer

What is a StackOverflow Error

Parameters and local variables are allocated on ...READ MORE

answered May 21, 2018 in Java by Parth
• 4,630 points
227 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,630 points
2,571 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
191 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
528 views