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
If you do not have Java installed, and the PATH variable is not set correctly, attempts to run a JAR file on Windows or Ubuntu will result in a 'Java not recognized' error. To run a JAR file, you must install the Java JDK or JRE on your computer.
To run an application in a nonexecutable JAR file, we have to use -cp option instead of -jar. We'll use the -cp option (short for classpath) to specify the JAR file that contains the class file we want to execute: java -cp jar-file-name main-class-name [args …]
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With