Sundararajan's Weblog

  • Java
    July 12, 2006

Bitten by whitespace

Guest Author
I was making a jar file for testing something. I had given a manifest file and a set of classes by the following command line:
jar cvfm myjar.jar mymanifest.mf \*.class

When I used myjar.jar, the manifest entries I specified in my mymanifest.mf were not working as expected. I opened the jar and checked the added manifest.mf in the jar file -- it did not have attributes defined in mymanifest.mf in it! In fact, my manifest.mf had just one attribute!! It turned out that I was bitten by whitespace -- newline was missing at the end of the attribute. Apparently, manifest file spec. mandates newline at the end of attributes. jar tool did not complain about my manifest file :-( Moral of the story: beware of whitespaces!

Join the discussion

Comments ( 1 )
  • murphee Wednesday, July 12, 2006
    And always trim() your filenames before using them anywhere or you'll also spend some happy hours trying to locate a bug, like me: http://jroller.com/page/murphee/20060620
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.