Last updated: Apr 4, 2024
Reading time·4 min
The error "'jar' is not recognized as an internal or external command, operable program or batch file" occurs for 3 main reasons:
jar.exe
file in your
system's PATH environment variable.JRE contains java
but doesn't contain jar
and javac
.
On the other hand, JDK contains java
, jar
and javac
.
You can try to issue the where java
command and look at the output to
determine if you have JRE or JDK installed.
where java
If you already have Java Development Kit (JDK) installed, scroll down to the
"Add the path to the jar
executable in your system's PATH environment
variable" subheading.
To install and configure Java Development Kit (JDK) on Windows:
jar -version
command.jar --version java -jar java -version
jar
command won't be available because the directory that contains the jar.exe
file isn't automatically added to PATH.If the error persists, you have to set the path to the jar
executable in your
system's PATH environment variable.
jar
executable in your system's PATH environment variableTo add the path to the jar
executable in your system's PATH environment
variable:
The path on my machine is the following:
# 👇️ this is the path on my machine (version may differ) C:\Program Files\Java\jdk-19\bin # 👇️ your path might also be similar to this C:\Program Files (x86)\Java\jdk-19\bin
jar.exe
file because this is the file that is run when you issue jar
commands.Notice that the path contains the jdk
version, so your path will likely be
different if your jdk
version differs.
Note that your path should not be under a folder named jre-XYZ
because Java
Runtime Environment (JRE) doesn't contain the jar
executable.
java
executable files (including jar.exe
),
add it and click on the "OK" button twice.You might also have to restart your PC, but that's not always necessary.
Open a new Command Prompt and run the jar --version
command to make sure the
jar
executable is accessible.
java -version javac -version jar --version
.exe
) files has been added to your system's PATH
environment variable, all java
commands should work.If the error persists, try restarting your PC to make sure you don't have any
stale CMD, PowerShell or IDE sessions and rerun the jar --version
command.
To solve the error "'jar' is not recognized as an internal or external command, operable program or batch file", make sure:
jar.exe
file in your
system's PATH environment variable.You can learn more about the related topics by checking out the following tutorials: