Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netbeans manifest

Tags:

Is it possible to add entries to the manifest.mf file of jars generated by netbeans?

to build an osgi bundle for instance.

like image 761
Maurice Perry Avatar asked Aug 06 '09 05:08

Maurice Perry


People also ask

How do I edit a manifest file in Netbeans?

I clicked over to the "Files" tab, double-clicked on "manifest. mf" in the "build" folder, and edited the file to include this.

What is manifest in Java?

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.

Where is the Java manifest file?

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.


2 Answers

Note that you can create a manifest on-the-fly via an ant task and set properties dynamically.

First, you must update your Netbeans "project.properties" file found in the "nbproject" directory. Add the following line to the file:

manifest.file=manifest.mf 

Next, create an ant task to create/update the manifest using the "build.xml" file. In this example, we will set the version number and date of the jar file.

<target name="-pre-init">    <property name="project.name" value="My Library" />    <property name="version.num" value="1.4.1" />    <tstamp>       <format property="NOW" pattern="yyyy-MM-dd HH:mm:ss z" />    </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="Bundle-Name" value="${project.name}" />                  <attribute name="Bundle-Version" value="${version.num}" />       <attribute name="Bundle-Date" value="${NOW}" />       <!--<attribute name="Bundle-Revision" value="${svna.version}" />-->       <attribute name="Implementation-Title" value="${project.name}" />       <attribute name="Implementation-Version" value="${version.num}" />       <attribute name="Implementation-URL" value="http://www.example.com" />    </manifest>  </target> 

This will create a manifest file in your netbeans project directory and stuff it into your jar file. If you want to delete the autogenerated manifest file from your netbeans project directory, simply create another ant task (post jar of course):

<target name="-post-jar">   <delete file="MANIFEST.MF"/> </target>  
like image 174
Peter Avatar answered Nov 06 '22 03:11

Peter


Interesting information might be here:

http://wiki.netbeans.org/FaqNoMainClass

like image 35
java.is.for.desktop Avatar answered Nov 06 '22 05:11

java.is.for.desktop