Reputation: 425
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
Reputation: 87
Five steps to solve this problem:
bin
folder jar.exe is available or notbin
folderjar xf filename.jar
Now see if it is working
Upvotes: 3
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
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
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