Java programs are often deployed in JAR format, a specialized kind of zip file. The manifest is a text file inside the JAR that describes the contents. Here's a simple program to read the manifest from one or more JAR files. You can read more about JAR files in the JAR tutorial and technotes. The attached JAR file, below, includes the source and an ant build script.

import java.util.Map;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;

 * Display the manifest of a jar file.
 * @see <a href="">JAR tutorial</a>
 * @author John B. Matthews
public class Manifesto { 

    public static void main(String[] args) { 
        if (args.length < 1) showHelp();
        else for (String name : args)
            try {
                System.out.println("Manifest: " + name);
                JarFile jar = new JarFile(name);
                Manifest manifest = jar.getManifest();
            } catch (Exception e) {
    private static void showMap(Attributes map) {
        if (map == null) return;
        for (Map.Entry<Object, Object> e : map.entrySet())
            System.out.println(e.getKey() + ": " + e.getValue());
    private static void showHelp() {
            "Usage: java -jar Manifesto.jar <jarfile> [<jarfile>]");

$ java -jar Manifesto.jar Manifesto.jar
Manifest: Manifesto.jar
Created-By: 1.5.0_16-133 (Apple Inc.)
Ant-Version: Apache Ant 1.7.0
Main-Class: Manifesto
Manifest-Version: 1.0

    Ant build file for Manifesto

    Targets suitable for NetBeans free-form project.

<project name="Manifesto" default="default" basedir=".">

<!-- set global properties for this build -->
<property name="proj" value="Manifesto"/>
<property name="main" value="Manifesto"/>
<property name="srcDir" value="."/>
<property name="buildDir" value="."/>
<property name="distDir" value="."/>
<property name="tempDir" value="temp"/>
<property name="javadocDir" value="javadoc"/>
<property name="jversion" value="1.5"/>
<property name="version" value="1.0.0"/>

<!-- Initialize -->
<target name="init" description="Initialize the build process.">
    <!-- Create a time stamp -->

<!-- Compile source files to class files -->
<target name="compile" depends="init" description="Compile the program.">
    <mkdir dir="${buildDir}"/>
    <javac srcDir="${srcDir}" destDir="${buildDir}"
        debug="on" source="${jversion}" target="${jversion}">
        <compilerarg value="-Xlint"/>

<!-- Build jar from classes -->
<target name="jar" depends="compile" description="Build a jar file.">
    <jar destfile="${distDir}/${proj}.jar">
            <attribute name="Main-Class" value="${main}"/>
        <fileset file="build.xml"/>
        <fileset file="${srcDir}/${main}.java"/>
        <fileset file="${buildDir}/${main}.class"/>

<!-- Run the program -->
<target name="run" depends="jar" description="Run the program.">
    <java jar="${distDir}/${proj}.jar" fork="true"></java> 

<!-- Run the program -->
<target name="test" depends="run" description="Test the program.">
    <java jar="${distDir}/${proj}.jar" fork="true">
    	<arg line="${proj}.jar"/>

<!-- Clean up all build/dist/temp directories -->
<target name="clean" description="Clean the project.">
    <delete dir="${javadocDir}"/>

<!-- Generate javadoc HTML documentation -->
<target name="doc" depends="compile" description="Generate the javadoc.">
    <mkdir dir="${javadocDir}"/>
        author="true" version="true"
        access="private" use="true"
        windowtitle="${proj} v${version} API">
        <fileset dir="${srcDir}">
            <include name="**/*.java"/>
            <![CDATA[<h2>${proj} v${version} API</h2>]]>
            <![CDATA[<i>Copyright &#169; 2008 Gem City Software.]]>

<!-- NetBeans debug target -->
<target  name="debug-nb" depends="compile" description="Debug the program in NetBeans.">
    <!-- Run the program -->
    <nbjpdastart addressproperty="jpda.address" name="${main}" transport="dt_socket">
        <classpath path="${buildDir}"/>
    <java classname="${main}" fork="true">
        <classpath path="${buildDir}"/>
        <jvmarg value="-Xdebug"/>
        <jvmarg value="-Xnoagent"/>
        <jvmarg value="-Djava.compiler=none"/>
        <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>

<!-- Default target -->
<target name="default" depends="clean, jar" description="Default clean and build.">


John Matthews,
Nov 14, 2010, 3:28 PM