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

Java

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

If you want to unleash your potential in this competitive field, please visit the Java course page for more information, where you can find the Java tutorials and Java frequently asked interview questions and answers as well.

2
Answers

Replies

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

 


This error “javac is not recognized as an internal or external command” may occurs when the java compiler (javac.exe) path is not set properly
As, we all know that we can set path of javac.exe in two ways:
•Temporary
•Permanent
But, I have seen that you set the path of javac.exe temporarily using the “set path” command. So you wrote something like this



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



You are getting an error [ 'javac' is not recognized as an internal or external command, operable program or batch file] due to missing backslash(\) before Program Files(x86) in the third line or statement of the above code.


So please correct the third statement “set path=C:\Program Files (x86)\Java\jdk1.7.0\bin” instead of “set path=C:Program Files (x86)\Java\jdk1.7.0\bin”.


Now, the javac.exe path is set temporary successfully and you can compile and execute your program.


Note: The error you were getting just because of “\” missing in path statement before Program Files(x86).


Correct Code:



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


 


 

 
 

This topic has been locked/unapproved. No replies allowed

Login to participate in this discussion.

Leave a reply

Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.
WhatsApp
To Top