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 parth295
• 4,620 points
30,083 views

11 answers to this question.

+5 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,540 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.
+3 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.

+3 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,560 points
work fine but not show path of java and ant in

environment variable
+3 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
+3 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
+1 vote

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
• 14,070 points
+1 vote

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,040 points
0 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
0 votes
Just add the path to your environment variable and you are good to go.
answered Nov 27, 2018 by Stefany
0 votes

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
0 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;

answered Feb 8 by rajesh
• 1,210 points

Related Questions In Java

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,880 points
83 views
+1 vote
3 answers

What is the syntax to declare and initialize an array in java?

You can use this method: String[] strs = ...READ MORE

answered Jul 25, 2018 in Java by samarth295
• 2,190 points
312 views
0 votes
2 answers

What is the syntax to initialize an array?

Rather than learning un-Official websites learn from ...READ MORE

answered Aug 2, 2018 in Java by samarth295
• 2,190 points
47 views
0 votes
1 answer

Is it possible to run a java program from command line on windows?How?

  Let's say your file is in C:\myprogram\ Run ...READ MORE

answered Apr 18, 2018 in Java by sophia
• 1,400 points
122 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 parth295
• 4,620 points
78 views
0 votes
1 answer

Non-static variable cannot be referenced from a static context. Explain?

Static fields and methods are connected to ...READ MORE

answered May 21, 2018 in Java by parth295
• 4,620 points
4,341 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 parth295
• 4,620 points
114 views
0 votes
2 answers

Connection reset : java.net.SocketException

You should check whether the client program is ...READ MORE

answered Sep 6, 2018 in Java by Sushmita
• 6,880 points
1,122 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,880 points
94 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 in Java by Jim
• 810 points
245 views