How to attach MANIFEST.MF file in jar in/using Netbeans?

UPDATED: 30 October 2013

Step 1: Open build.xml file in notepad or other editor and paste below code within <project>...</project>
<target name="-pre-init">
        <property name="project.name" value="Name of your llibrary"/>
        <property name="version.num" value="1.4.1"/>
        <tstamp>
            <format pattern="yyyy-MM-dd HH:mm:ss z" property="NOW"></format>
        </tstamp>

    <!--
    <exec outputproperty="svna.version" executable="svnversion">
     <arg value="-c" />
     <redirector>
      <outputfilterchain>
       <tokenfilter>
        <replaceregex pattern="^[0-9]*:?" replace="" flags="g"/>
        <replaceregex pattern="M" replace="" flags="g"/>
       </tokenfilter>
      </outputfilterchain>
     </redirector>
    </exec>
    -->
        <manifest file="MANIFEST.MF">
            <attribute name="Codebase" value="*"/>           
            <attribute name="Permission" value="all-permissions"/>
            <attribute name="Application-Library-Allowable-Codebase" value="javaquery.com"/>
            <attribute name="Caller-Allowable-Codebase" value="www.javaquery.com javaquery.com"/>
            <attribute name="Application-Name" value="javaQuery"/>
            <attribute name="Bundle-Name" value="${project.name}"/>           
            <attribute name="Bundle-Version" value="${version.num}"/>
            <attribute name="Bundle-Date" value="${NOW}"/>
            <attribute name="Implementation-Title" value="${project.name}"/>
            <attribute name="Implementation-Version" value="${version.num}"/>
            <attribute name="Implementation-URL" value="http://www.javaquery.com"/>
            <!--<attribute name="Bundle-Revision" value="${svna.version}" />-->
        </manifest>
 </target>

Step 2: Edit your required details in attributes. Uncomment the SVN version code if you want to put SVN version details in MANIFEST.MF file

Step 3: Save build.xml file

Step 4: Set your project as main project in netbeans. Now Go to RUN > Clean and build main project

Step 5: Find your output jar file in dist folder of project.

Other Resources:
How to attach MANIFEST.MF file in jar in/using eclipse?
How to create .jar file in netbeans?

0 comments :