Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 542
Coder Lam Avatar asked Mar 21 '15 08:03

Coder Lam


People also ask

Why JAR file is not recognized?

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.

How do I run a .JAR file?

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 …]


2 Answers

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

like image 165
Joseph Mekwan Avatar answered Oct 04 '22 01:10

Joseph Mekwan


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 
like image 26
Aleksandr Šmailov Avatar answered Oct 04 '22 02:10

Aleksandr Šmailov