Coder Lam
Coder Lam

Reputation: 425

java 'jar' is not recognized as an internal or external command

I'm getting the following error when I try to run the 'jar' command in the command line on windows : 'jar' is not recognized as an internal or external command

The general solution seems to be that I need to add the jdk bin folder to the PATH in environment variables. I have already done this, I added the following to the path variable : ...; C:\Program Files\Java\jdk1.8.0_40\bin\;

Though I'm not sure if having the jdk reside in 'program files' instead of 'program files x86' affects this. I'm on 64 bit windows with 64 bit java. Thanks

Upvotes: 28

Views: 151232

Answers (4)

Manukundloo
Manukundloo

Reputation: 87

Five steps to solve this problem:

  1. check whether in your bin folder jar.exe is available or not
  2. check for your environmental setting
  3. download jar file from here http://originaldll.com/file/jar.exe/29248.html and keep in bin folder
  4. now check for jar it will 100% work
  5. keep any jar in your desktop and go to desktop path on cmd prompt and run the command jar xf filename.jar

Now see if it is working

Upvotes: 3

Joseph Mekwan
Joseph Mekwan

Reputation: 1092

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

Thanks To : @stevevls

Upvotes: 23

Przemek Nowak
Przemek Nowak

Reputation: 7713

The jar command in command line is used in order to create a JAR file. For example:

 jar cf jar-file input-file(s)

See more at: Oracle docs

If you want to run the existed JAR file you should use the java -jar command mentioned by @Aleksandr.

But in your case it looks like you don't have an access to the added directory in your path with JKD binaries so at the beginning try to execute mentioned java --version to check whether you have java in you classpath at all.

Please remember that on Windows you have to restart the console when you change the windows default path. You do not see the changes on the current console.

The x64 version of Java is installed on Program Files. The x86 version is installed on Program Files x86 by default.

Upvotes: 3

Aleksandr Šmailov
Aleksandr Šmailov

Reputation: 246

Try using this command:

java -version

If it doesn't work that means you failed to properly add path to jdk. If it does work, try using:

java -jar

Upvotes: 12

Related Questions