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

When I run javac Main.java, I get the error: ‘javac’ is not recognized as an internal or external command, operable program or batch file. I am using Windows PC, did anyone manged to solve this issue?
javac

Hi.
Check your path variable. For instance type this in the command prompt

echo %path%

image

in PowerShell

$env:path

image

You should see any reference to java or JDK within

Simpler method should you edit is to open the environment variable dialog

image

and look for path in there.

Good luck.

Thank you for the response. If I do echo %path% or $env:path I do not get any reference to java or JDK within:

echo %path%

How do I edit is to open the environment variable dialog?

Thank you

Hit the Windows key and type “environ”…

What do I do after opening the Environment variables?

Thank you

The dialog is split in halves. The upper half will apply only to you as a user and the bottom one will affect the whole system.

For instance if you have multiple accounts on the computer but want Java available only for yourself in the command line edit the path variable in the upper half. Otherwise in the bottom half.

In my system it looks like this

image

Select Path then click Edit…

Then in the set of buttons on the right either click on New to provide the path to Java manually

image

Otherwise click on Browse… if you prefer select the path visually.

image

Go to your Java folder including the bin subfolder.

For instance on my machine the path is E:\Program Files\Microsoft\jdk-11.0.17.8-hotspot\bin.

You may need to logout/login back to you session, or just close any open console or restart the computer at all to have it work. Then javac should be recognized.

This step of adding Java to your Path variable is actually what you’d do should you install from an archive.

2 Likes