I have a .bat file, which contains the following contents

... jar cfm myjar.jar manifest.txt *.class ...

Which executes well under windows command prompt, but when executed under cygwin, I get the following C:\cygwin\home\user\path\to\folder>jar cfm myjar.jar manifest.txt *.class Access is denied.

I tried starting cygwin as administrator, but it does not help

Would appreciate any suggestions


2 Answers 2


ok, do a ls -la on the dir youre trying to write the jar into, as well as the class files and manifest. see what cygwin thinks the premissions are for everything in question.

you may have to open up the perms from the windows side to 'Everybody' using cacls.

also make sure that cygwins path to jar is the same as windows.

  • thanks for suggestions, but I've tried all that, and also changing ownership of all the class files and jar destination directory, but nothing seems to work
    – user59476
    Nov 7, 2010 at 22:52
  • If you run the jar command from a bash script instead of the bat file does it work? Is there some envvar that's cygwin is missing?
    – Dr. McKay
    Nov 7, 2010 at 23:50
  • yes, if i run the command from a bash it does work; it only fails when it's run within a bat file
    – user59476
    Nov 8, 2010 at 8:45
  • Is it possible that the CLASSPATH or some other environment variable is not being set when starting the bat file from bash? I assume when you do that bash launches cmd which launches bat which launches jar?
    – Dr. McKay
    Nov 10, 2010 at 18:26

I had the same problem. It worked when I wrote "bash" "filename".bat. You also have to write bash inside a .bat script if it calls for other .bat files.

  • This is very hard to understand and some examples would help.
    – Sven
    Feb 13, 2015 at 7:21

You must log in to answer this question.