Why is java or javac unrecognized as commands?

This can happen for a few reasons:

  • You have not correctly added the jdk to your path environment variable. Ensure that you have done so correctly.
  • The Command Prompt or CLI service was open from before you added the jdk to your path environment variable. You simply need to restart this service.
  • You have not installed a version of java that is compatible with your machine. Double check that you have the right bitness (x64 or x86).
  • You have a Java installation but have not installed the JDK correctly, in which case javac would not be recognized. You can find the links to it in the above FAQ. If properly installed, you should be able to find a jdk folder inside your Java installation folder (C:\Program Files (x86)\Java\)

    When you've tried all these fixes, verify your installation by opening a Command Prompt and running:

sh

1java --version

and

sh

1javac

The first should return a valid version number and the second should give a list of options and flags.

If you still have any issues running java commands, set the JAVA_HOME environment variable.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales