I am getting a too long line error while trying to build a jar. the long line in the manifest file is the Class-Path line as the application uses a lot of third-party libraries. needless to say, I am using Windows :-( and Eclipse Java 1.6
I tried Class-Path: lib
or Class-Path: lib/
but they did not work.
To modify the manifest, you must first prepare a text file containing the information you wish to add to the manifest. You then use the Jar tool's m option to add the information in your file to the manifest. Warning: The text file from which you are creating the manifest must end with a new line or carriage return.
The answer is the JAR file's manifest. The manifest is a special file that can contain information about the files packaged in a JAR file. By tailoring this "meta" information that the manifest contains, you enable the JAR file to serve a variety of purposes.
The manifest file is named MANIFEST. MF and is located under the META-INF directory in the JAR. It's simply a list of key and value pairs, called headers or attributes, grouped into sections.
The classpath is too long due to the number of jar files in it. «No line may be longer than 72 bytes (not characters), in its UTF8-encoded form.» [from docs: java 5, java 8; «Line length» section].
use as the following way to resolve the problem:
(1) use separate lines, to avoid too long a line for java package name lists
(2) type a preceding space before each folloing lines, for example:
Class-Path:
...jar
...jar
...jar
The single character didn't work for me (Java 8, IntelliJ). I used two characters at the start and no characters at the end of the line (wasn't apparent from the above example) and two new lines at the end, e.g.
Manifest-Version: 1.0
Main-Class: com.mypackage.MyApp
Implementation-Version: 2.0.0
Class-Path: newLibs/asjava.zip
newLibs/activation.jar
newLibs/axis-ant.jar
newLibs/axis.jar
newLibs/bcel-5.1.jar
newLibs/commons-discovery-0.2.jar
newLibs/commons-logging-1.0.4.jar
newLibs/datanucleus-api-jdo-4.2.0-release.jar
newLibs/datanucleus-api-jpa-4.1.4.jar
newLibs/datanucleus-cache-4.0.4.jar
newLibs/datanucleus-core-4.1.5.jar
newLibs/datanucleus-geospatial-4.1.0-release.jar
newLibs/datanucleus-guava-4.1.3.jar
newLibs/datanucleus-java8-4.2.0-release.jar
newLibs/datanucleus-jdo-query-4.2.0-release.jar
newLibs/datanucleus-jodatime-4.1.1.jar
newLibs/datanucleus-jpa-query-4.0.4.jar
newLibs/datanucleus-rdbms-4.1.6.jar
newLibs/dom4j-1.6.1.jar
newLibs/ehcache-1.1.jar
newLibs/ehcache-core-2.2.0.jar
newLibs/geronimo-jta_1.1_spec-1.1.jar
newLibs/guava-15.0.jar
newLibs/h2-1.3.168.jar
newLibs/ibmjsse.jar
newLibs/javax.jdo-3.2.0-m3.jar
newLibs/javax.persistence-2.1.1.jar
newLibs/jaxrpc.jar
newLibs/jdo-api-3.1-rc1.jar
newLibs/jdom.jar
newLibs/joda-time-1.6.jar
newLibs/jtds-1.2.jar
newLibs/log4j-1.2.14.jar
newLibs/mail.jar
newLibs/saaj.jar
newLibs/servlet-api.jar
newLibs/wsdl4j-1.5.1.jar
newLibs/xercesImpl.jar
newLibs/xml-apis.jar
I also avoided placing multiple jars on one line as that didn't appear to work (even with lines less than 72 bytes).
What led me to arrive at this solution was (1) I kept getting various class not found exceptions, of course and (2) When I examined the generated manifest file in the jar file, the spacing between the jars was missing - I assume that it was silently failing because there was no reported error apart from the class not found exceptions. My working, generated manifest file looks like this:
Manifest-Version: 1.0
Implementation-Version: 2.0.0
Class-Path: newLibs/asjava.zip newLibs/activation.jar newLibs/axis-an
t.jar newLibs/axis.jar newLibs/bcel-5.1.jar newLibs/commons-discovery
-0.2.jar newLibs/commons-logging-1.0.4.jar newLibs/datanucleus-api-jd
o-4.2.0-release.jar newLibs/datanucleus-api-jpa-4.1.4.jar newLibs/dat
anucleus-cache-4.0.4.jar newLibs/datanucleus-core-4.1.5.jar newLibs/d
atanucleus-geospatial-4.1.0-release.jar newLibs/datanucleus-guava-4.1
.3.jar newLibs/datanucleus-java8-4.2.0-release.jar newLibs/datanucleu
s-jdo-query-4.2.0-release.jar newLibs/datanucleus-jodatime-4.1.1.jar
newLibs/datanucleus-jpa-query-4.0.4.jar newLibs/datanucleus-rdbms-4.1
.6.jar newLibs/dom4j-1.6.1.jar newLibs/ehcache-1.1.jar newLibs/ehcach
e-core-2.2.0.jar newLibs/geronimo-jta_1.1_spec-1.1.jar newLibs/guava-
15.0.jar newLibs/h2-1.3.168.jar newLibs/ibmjsse.jar newLibs/javax.jdo
-3.2.0-m3.jar newLibs/javax.persistence-2.1.1.jar newLibs/jaxrpc.jar
newLibs/jdo-api-3.1-rc1.jar newLibs/jdom.jar newLibs/joda-time-1.6.ja
r newLibs/jtds-1.2.jar newLibs/junit-3.8.1.jar newLibs/log4j-1.2.14.j
ar newLibs/mail.jar newLibs/saaj.jar newLibs/servlet-api.jar newLibs/
wsdl4j-1.5.1.jar newLibs/xercesImpl.jar newLibs/xml-apis.jar
Main-Class: com.mypackage.MyApp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With