Search code examples
javajar

Error - jar is not recognized as an internal or external command, operable program or batch file


I get the error mentioned above when I execute jar command in cmd. I tried to solve this problem by going putting the path of the jar.exe file in the "path" variable in My computer> > settings > advanced system settings > environment variables.

This is how i did it -

(old path variables here);C:\Program Files (x86)\Java\jdk1.7\bin\jar.exe 

I saved the changes and tried to run jar in cmd again and got the same error. Please tell me my mistake and how to fix it. I need to make this work so that I can create jar files via the command line.


Solution

  • The path should only contain directories where the OS will look for executables. Strip the trailing "\jar.exe" to set your path as:

    (old path variables here);C:\Program Files (x86)\Java\jdk1.7\bin