Solve javac is not recognized as an internal or external command Error

The error javac is not recognized as an internal or external command arises when we try to compile any java source file using javac command. The reason for this error is because the path of javac command is not set properly.

This error can be solved easily by setting javac compiler path in environment variables.

Solve javac is not recognized as an internal or external command Error

How to solve javac is not recognized as an internal or external command Error?

This can be done in two ways as given below.

 

Temporary Path Setting

This method is temporary because after setting path you can work with javac command until command prompt is not closed.

 

1. Go to the bin folder inside JDK folder. Most probably it can be found in Program Files > Java > jdk > bin

It may look like this C:\Program Files\Java\jdk1.8.0_45\bin

Don’t just copy above path, it may vary according to your installation location and java version.

 

2. Now open command prompt and type following command.

set path=”C:\Program Files\Java\jdk1.8.0_45″

Just replace the path with your bin folder path.

 

3. Press enter and you have done. Now you can compile java file without any error.

 

Permanent Path Setting

This method is permanent as even after closing command prompt, javac command will work to compile java files.

 

1. Go to the bin folder inside JDK folder. Most probably it can be found in Program Files > Java > jdk > bin

It may look like this C:\Program Files\Java\jdk1.8.0_45\bin

Don’t just copy above path, it may vary according to your installation location and java version.

 

2. Now right click on Computer then click Properties.

javac 1

 

3. In the new window click on Advance system settings and then Environment Variables.

javac 2

 

4.Click on new button. In Variable name filed type path and in Variable value field paste the path that you have copied.

javac 3

 

5. Finally click on all OK buttons to save the settings. You have done. Now you can compile java file without any error.

 

Check Path Setting

You can check the path setting is done properly or not by just typing javac and then press enter in cmd.

If you get some details of javac as shown in below image then everything is done properly. In case you get the same error as earlier then you have done something wrong. Just follow the process again properly.

javac 4

 

In case you are facing any problem you can ask your queries in comment section.

2 thoughts on “Solve javac is not recognized as an internal or external command Error”

  1. Thanks. It worked

    1. Go to the bin folder inside JDK folder. Most probably it can be found in Program Files > Java > jdk > bin

    It may look like this C:\Program Files\Java\jdk1.8.0_45\bin

    Don’t just copy above path, it may vary according to your installation location and java version.

    2. Now open command prompt and type following command.
    C:\Program Files\Java\jdk1.8.0_221\bin

    Thanks

Leave a Comment

Your email address will not be published. Required fields are marked *