Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is use of MANIFEST.MF in WAR/JAR/EAR?

Tags:

I am aware of usage of MANIFEST file in a mobile application, but am not aware of usage of same in a Java Application.

My guess say like, its being used to keep BUILD information only. Am I correct??

Is this Mandatory?If not, then what are the key benefits that we can draw with this?

like image 826
Ashish Agarwal Avatar asked Jun 21 '12 13:06

Ashish Agarwal


People also ask

What is the use of manifest file in JAR?

What gives a JAR file this versatility? The answer is the JAR file's manifest. 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.

What is manifest MF in war?

manifest.mf carries attributes of the artifact. One of the most well known ones is for example the main class of the jar that is used to start the jar file when no other class is specified. Syntax: Main-Class: classname. Other purposes are, for example, package sealing and package versioning.

Why do we use manifest MF?

Manifest. MF contains information about the files contained in the JAR file. These are entries as “header:value” pairs. The first one specifies the manifest version and second one specifies the JDK version with which the JAR file is created.

How do I add manifest MF to JAR?

You use the m command-line option to add custom information to the manifest during creation of a JAR file. This section describes the m option. The Jar tool automatically puts a default manifest with the pathname META-INF/MANIFEST. MF into any JAR file you create.


1 Answers

manifest.mf carries attributes of the artifact. One of the most well known ones is for example the main class of the jar that is used to start the jar file when no other class is specified. Syntax:

Main-Class: classname 

Other purposes are, for example, package sealing and package versioning. Check out the java tutorial about it: http://docs.oracle.com/javase/tutorial/deployment/jar/manifestindex.html

A manifest in a jar usually contains much less information than for example AndroidManifest.xml. It is quite lightweight and does not contain any build or packaging information.

This is because java has no good module system. So, a jar is not a module which might need a lot of configuration information (like a list of modules to which it has dependencies). Instead, a jar is just a bunch of classes with some configuration information. Hopefully, this will be fixed by project jigsaw (http://openjdk.java.net/projects/jigsaw/).

like image 197
gexicide Avatar answered Oct 18 '22 16:10

gexicide