Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding custom tags to jar manifest

Tags:

java

jar

manifest

I have a requirement wherein I wanted to put some user defined tags in jar manifest file. I was wondering if it is possible to do so?

  • If yes, any example?
  • if no. :( why not?
like image 278
test Avatar asked May 09 '11 18:05

test


People also ask

How do I edit a JAR file manifest?

To modify the manifest, you must first prepare a text file containing the information you wish to add to the manifest. You then use the Jar tool's m option to add the information in your file to the manifest. Warning: The text file from which you are creating the manifest must end with a new line or carriage return.

Where do I put manifest file in JAR?

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.


1 Answers

I was wondering if it is possible to do so?

Yes.

If yes, any example?

silly-word: supercalafragilisticexpyaladocious

Custom enough for you?

See specifically the JAR File Specification: Manifest Specification for details on attributes and values.

  • manifest-file: main-section newline *individual-section
  • main-section: version-info newline *main-attribute
  • version-info: Manifest-Version : version-number
  • version-number : digit+{.digit+}*
  • main-attribute: (any legitimate main attribute) newline
  • individual-section: Name : value newline *perentry-attribute
  • perentry-attribute: (any legitimate perentry attribute) newline
  • newline : CR LF | LF | CR (not followed by LF)
  • digit: {0-9}

In the above specification, attributes that can appear in the main section are referred to as main attributes, whereas attributes that can appear in individual sections are referred to as per-entry attributes. Certain attributes can appear both in the main section and the individual sections, in which case the per-entry attribute value overrides the main attribute value for the specified entry. The two types of attributes are defined as follows. ..

like image 132
Andrew Thompson Avatar answered Oct 11 '22 13:10

Andrew Thompson