Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

One of the tools that I maintain has recently been updated with new functionality and as a result we had to update its MANIFEST.MF file to reference additional jar files in its classpath. Unfortunately the number of referenced jar files went over a limit and during Maven build the following error started to crop up...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.6:jar (default-jar) on project MyProject: Error assembling JAR: Unable to read manifest file (line too long) -> [Help 1]

The official documentation had the following note:
Line length:
No line may be longer than 72 bytes (not characters), in its UTF8-encoded form. If a value would make the initial line longer than this, it should be continued on extra lines (each starting with a single SPACE).

In my case, the line length was definitely over 72 bytes, so I proceeded to split each of the jar file dependencies out into its own line. My initial cut of the change had each new jar starting on a new line with a single space character at the beginning of the line. Unfortunately that produced garbage results - it appears that the single space character at the start of a line is a line continuation marker and is stripped when the full line is put together. This results in something like "dep-jar-1.jardep-jar-2.jardep-jar-3.jar..." being created.

Since we want each jar to be separate, a double space is required at the beginning of each line! This looks like the following...
Manifest-Version: 1.0
Main-Class: net.igorkromin.MainClass
Class-Path: dep-jar-1.jar

With double spaces in place, everything worked as expected!


A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.