tags:

views:

226

answers:

5

Hello everyone, How can I create a manifest file for a group of .jar file I' ve already created. I used eclipse to create my .jar file, is there any better way of creating a .jar file that has a manifest?

Thanks

A: 

A default manifest file is created when you create a jar using jar cf jar-file inputs-files.

JG
+1  A: 

A manifest is a simple text file, Sun's tutorial describes its contents in detail.

All you have to do is create such a file and update the JAR files with this command:

jar cfm <jar-file> <manifest-addition>
Michael Borgwardt
A: 

Manifest files are text files. And since JAR files are actually ZIP files, you can also add the manifest using a tool like 7-zip. This doesn't work for signed JARs, of course.

Joonas Pulakka
+1  A: 

Eclipse provides options to generate a manifest file for the Jar, save that generated manifest into the project, or use a specified file for the manifest.

I have Eclipse 3.4.2 and it's on the fourth screen in this process:

Right-click Project -> Export -> Java/JAR file, Next, JAR File Specification, Next, JAR Packaging Options, Next, JAR Manifest Specification.

The default is to just generate a default manifest for the JAR, and not to save the generated file back to the project, so if you open up your JAR file, it will have a manifest, but it will just have something like:

Manifest-Version: 1.0

in it.

If you want to change your existing JARs without re-building them, the easiest way is probably to just do as mad-j suggested and open them with a Zip tool and edit the existing /META-INF/MANIFEST.MF file and save it back into the JAR.

Nate
A: 

With Ant you can use jar task. It has a manifest option to specify all the attributes yo need to include. Something like this:

  <target name="create-my-jar">
     <jar jarfile="foo.jar" basedir="bin/classes">   
        <manifest>
        <attribute name="Class-Path" value="xxx"/>
        <attribute name="Ant-Version" value="${ant.version}"/> 
        <attribute name="Created-By" value="JDK ${java.version} (${java.vendor})"/>
        <attribute name='Specification-Title' value='xxx' />
        <attribute name='Specification-Version' value='xxx' />
        <attribute name='Specification-Vendor' value='xxx' />
        <attribute name='Implementation-Title' value='xxx' />
        <attribute name='Implementation-Version' value='xxx' />
        <attribute name='Implementation-Vendor' value='xxx' />
        <attribute name='Implementation-Vendor-Id' value='xxx' />
        <attribute name='Implementation-Vendor-URL' value='xxx' />
        <attribute name="Built-By" value="${user.name}"/>
        <attribute name='Build-Date' value='xxx'/>
        <attribute name='Build-Time' value='xxx'/>    
        </manifest>
        </jar>
   </target>
JuanZe