Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / June 2004

Tip: Looking for answers? Try searching our database.

ANT-generated JAR-Manifest truncated at column 72!

Thread view: 
Richard Chrenko - 02 Jun 2004 14:56 GMT
I have an Ant script (version 1.5) to generate an executable JAR-file which
I use to deploy my Java application. The JAR-file has a manifest file
including a "Main-Class" tag to start the application as well as a "Class-
Path" tag to list the required libraries. However, if I inspect the
contents of the manifest file I see that Ant has inserted a CR-LF-SPACE
combination every 72 characters, thus corrupting the data. How can I create
a Class-Path entry in my JAR-manifest which is longer than 72 characters?

----------------
***Ant script***
----------------

<project name="Polysun4 BuildDeploy" default="jar">

   <description>
       Polysun 4:
       Kompiliert das ganze Projekt, erzeugt alle Jar-Files und kopiert
das ganze ins Verzeichnis Deploy.

       Folgende Pfade muessen gesetzt sein:
       ANT_HOME  = D:\jakarta-ant-1.5
       JAVA_HOME = D:\j2sdk1.4.2_01
       Path      = ...;D:\jakarta-ant-1.5\bin\
   </description>

   <path id="classpath">
       <pathelement location="lib/polysun/"/>
       <pathelement location="lib/forms.jar"/>
       <pathelement location="lib/hsqldb.jar"/>
       <pathelement location="lib/itext.jar"/>
       <pathelement location="lib/jcommon.jar"/>
       <pathelement location="lib/jfreechart.jar"/>
       <pathelement location="lib/jh.jar"/>
       <pathelement location="lib/plastic.jar"/>
       <pathelement location="lib/rreport.jar"/>
       <pathelement location="trans/Trans.jar"/>
       <pathelement location="trans/Trans_de.jar"/>
       <pathelement location="trans/Trans_en.jar"/>
       <pathelement location="trans/Trans_fr.jar"/>
       <pathelement location="help/Help_de.jar"/>
       <pathelement location="help/Help_en.jar"/>
       <pathelement location="help/Help_fr.jar"/>
   </path>
   <property name="cp" refid="classpath"/>

   <target name="jar" description="Alle Jar-Files erstellen">
       <jar jarfile="./deploy/Polysun4/Polysun.jar" basedir="./classes/">
<manifest>
               <attribute name="Main-Class" value="ch.spf.PS4Gui.PS4Gui"/>
               <attribute name="Class-Path" value="${cp}"/>
           </manifest>
       </jar>
   </target>

</project>

------------
***Result***
------------

Manifest-Version: 1.0
Created-By: Apache Ant 1.5
Main-Class: ch.spf.PS4Gui.PS4Gui
Class-Path: E:\polysun4\dev\polysun4Sources\lib\polysun;E:\polysun4\de
v\polysun4Sources\lib\forms.jar;E:\polysun4\dev\polysun4Sources\lib\h
sqldb.jar;E:\polysun4\dev\polysun4Sources\lib\itext.jar;E:\polysun4\d
ev\polysun4Sources\lib\jcommon.jar;E:\polysun4\dev\polysun4Sources\li
b\jfreechart.jar;E:\polysun4\dev\polysun4Sources\lib\jh.jar;E:\polysu
n4\dev\polysun4Sources\lib\plastic.jar;E:\polysun4\dev\polysun4Source
s\lib\rreport.jar;E:\polysun4\dev\polysun4Sources\trans\Trans.jar;E:\
polysun4\dev\polysun4Sources\trans\Trans_de.jar;E:\polysun4\dev\polys
un4Sources\trans\Trans_en.jar;E:\polysun4\dev\polysun4Sources\trans\T
rans_fr.jar;E:\polysun4\dev\polysun4Sources\help\Help_de.jar;E:\polys
un4\dev\polysun4Sources\help\Help_en.jar;E:\polysun4\dev\polysun4Sour
ces\help\Help_fr.jar
Richard Chrenko - 03 Jun 2004 11:15 GMT
The problem was actually a missing jar file reference, and the truncated
lines (which are apparently due to a peculiarity when viewing JAR-file
contents with a text editor) threw me way off track.

Sorry for the false alarm!
Pedro - 03 Jun 2004 21:29 GMT
> I have an Ant script (version 1.5) to generate an executable JAR-file
> which I use to deploy my Java application. The JAR-file has a manifest
[quoted text clipped - 4 lines]
> How can I create a Class-Path entry in my JAR-manifest which is longer
> than 72 characters?

It is not corrupted. Ant is supposed to do that. From the JAR File specifation:
<quote src="http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html">
- 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).
</quote>

Regards,
Pedro


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.