Scarlett Ideas Back to catalog
Effortlessly Fix ‘jar’ is Not Recognized as an Internal or External Command – A Warm, Step‑by‑Step Guide for Every Java Developer
Aug 28, 2026 Scarlett

Java: Not Recognized in Windows Command Prompt, Here's the Fix

Have you ever encountered the frustrating message "'java' is not recognized as an internal or external command" when trying to compile or run your Java project?...

Have you ever encountered the frustrating message "'java' is not recognized as an internal or external command" when trying to compile or run your Java project? This error likely arises because your system's command prompt or terminal cannot find the Java executable in your system's PATH. Let's delve into understanding this issue and explore robust solutions to resolve it.

Effortlessly Fix ‘jar’ is Not Recognized as an Internal or External Command – A Warm, Step‑by‑Step Guide for Every Java Developer

Java is a widely-used programming language, and its command-line interface (CLI) tools are indispensable for developers. However, if you're seeing the aforementioned error, it's interrupting your workflow, and it's crucial to address it promptly.

How to Fix the ‘jar is not recognized as an internal or external command’ Error – Complete Troubleshooting Guide

Understanding the Error Message

The error message "'java' is not recognized as an internal or external command" implies that the command prompt or terminal couldn't find the Java executable. Here, we'll discuss the possible reasons behind this issue and how to rectify them.

Fix 'mvn' is Not Recognized as an Internal or External Command: Complete Guide

When you type a command, your system searches for an executable file with that name within directories listed in the PATH environment variable. If it doesn't find the Java executable, it throws this error.

Java Not Added to PATH

How to Fix ‘jar’ Is Not Recognized as an Internal or External Command Error – Step-by-Step 2025 Guide

One of the primary reasons for encountering this error is that the Java bin directory is not included in the system's PATH variable. During Java installation, the bin directory is usually added to the PATH automatically, but sometimes this step might be skipped.

To fix this, you can manually update your system's PATH to include the Java bin directory. The process differs based on your operating system; we'll discuss this in detail later in the article.

Incorrect Java Version

Java Interview Questions #27 | HashMap Internals Explained | How put() and get() Work

Another possibility is that you're trying to run a Java command from a Java version that is not recognized by your command prompt or terminal. For instance, if your system has both Java 8 and Java 11 installed, typing 'java' at the prompt might execute the Java 8 command even if you're under a Java 11 environment.

To verify which Java version you're currently using, type 'java -version' at the prompt. If it shows the wrong version, ensure that the correct Java version is added to the system's PATH.

Resolving the Error: Step-by-Step

Java

Now that we've discussed the underlying causes of this error, let's explore step-by-step solutions to resolve it, tailored to different operating systems.

Remember, the solutions depend on your operating system (Windows, macOS, or Linux), your current Java version, and whether you're using the command prompt (Windows), Terminal (macOS), or Terminal or command line (Linux).

a hand touching a computer screen with the word ava on it in front of an abstract background
an image of a computer screen with many lines on the screen and text below it
Java’s Security & Platform Independence Explained ☕💻
a computer screen with some type of programming program on it's back drop down
Java programming language details
the text is written in black and white
a diagram showing the different types of data
an image of a computer screen with text and numbers on the bottom right hand corner
Java’s Hilarious Tantrum: Unreported Exception IOException Must Be Caught or Declared to Be Thrown — A Survival Guide

Windows Users

Adding Java to PATH Environment Variable

If Java is not in your system's PATH, add the Java bin directory to it:

  1. Search for and open 'Environment Variables' in your system settings.
  2. In the 'System variables' section, scroll down and select the 'Path' variable.
  3. Click on 'Edit...', then 'New', and add the Java bin directory (usually 'C:\Program Files\Java\jdkX.X.X\bin', replacing 'X.X.X' with your Java version).
  4. Click 'OK' and restart your command prompt for the changes to take effect.

Specifying Java Version

If you're running a specific Java version, ensure you use the correct command:

java -version (replace 'version' with your desired version, e.g., '11')

macOS and Linux Users

Editing the .bash_profile or .zshrc File

For macOS or Linux users, edit your .bash_profile or .zshrc file in a text editor like nano or vim:

  1. Open Terminal.
  2. Type 'nano ~/.bash_profile' (or 'nano ~/.zshrc' for zsh users) and press Enter.
  3. Add this line at the end: export PATH="/path/to/java/bin:$PATH" (replace '/path/to/java/bin' with your actual Java bin directory).
  4. Press Ctrl + X to exit, then Y to save changes, and Enter to confirm the filename.
  5. Restart your Terminal for the changes to take effect.

In this comprehensive guide, we've explored the causes behind the "'java' is not recognized as an internal or external command" error, along with remedies to address it on various operating systems. By following these steps, you should now be able to run Java commands without encountering this error.

An optimized and robust development environment is crucial for productive coding. Mastering these troubleshooting techniques will allow you to counteract issues like this one promptly, helping you stay focused on writing powerful code. Happy coding!

More shots

Effortlessly Fix ‘jar’ is Not Recognized as an Internal or External Command – A Warm, Step‑by‑Step Guide for Every Java Developer
Effortlessly Fix ‘jar’ is Not Recognized as an Internal or External Command – A Warm, Step‑by‑Step Guide for Every Java Developer
How to Fix the ‘jar is not recognized as an internal or external command’ Error – Complete Troubleshooting Guide
How to Fix the ‘jar is not recognized as an internal or external command’ Error – Complete Troubleshooting Guide
Fix 'mvn' is Not Recognized as an Internal or External Command: Complete Guide
Fix 'mvn' is Not Recognized as an Internal or External Command: Complete Guide
How to Fix ‘jar’ Is Not Recognized as an Internal or External Command Error – Step-by-Step 2025 Guide
How to Fix ‘jar’ Is Not Recognized as an Internal or External Command Error – Step-by-Step 2025 Guide
Java Interview Questions #27 | HashMap Internals Explained | How put() and get() Work
Java Interview Questions #27 | HashMap Internals Explained | How put() and get() Work
Java
Java
a hand touching a computer screen with the word ava on it in front of an abstract background
a hand touching a computer screen with the word ava on it in front of an abstract background
an image of a computer screen with many lines on the screen and text below it
an image of a computer screen with many lines on the screen and text below it

Related topics