0

I need to create .jar using .bat. When I run this command from cmd it is ok:

jar -cMf ../sp.jar META-INF/MANIFEST.MF *class

but when I run batch file (.bat) with this command inside i says:

'jar' is not recognized as an internal or external command, operable program or batch file.

What should I do? When I try in cmd run javac or jar it is ok.

1
  • 1
    Set your path or use the fully qualified command name (including the path). Commented Oct 26, 2016 at 20:38

1 Answer 1

1

The command you give is a little confusing; by giving "M" as parameter you specify that you want to create a jar without a Manifest. By using "m" it means that you want to create a jar and then specify the manifest.

Please see http://www.dummies.com/programming/java/how-to-use-the-jar-command/

Also, I would use "jar cmf" instead of "jar -cMf" (whithout the "-").

In the end, try using the full path to where you have your jdk, something like: "c:\Program Files\Java\jdk1.your.version\bin"

Sign up to request clarification or add additional context in comments.

1 Comment

There are (at least) three alternate solutions to resolve the error: (a) Use the full path to the jar executable in the .bat file (b) Execute the bat file through a shortcut and set the "start in" folder to the location of the jar file (c) Modify the system paths to include the location of the jar executable hence rendering future references to the full path unneccessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.