23

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?

Aaron Bertrand
  • 272,866
  • 37
  • 466
  • 490
Ashish Agarwal
  • 6,215
  • 12
  • 58
  • 91
  • for example, you can use it for versioning, as explained here: http://www.jcabi.com/jcabi-manifests/versioning.html – yegor256 Dec 30 '12 at 08:53

1 Answers1

20

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/).

AdrieanKhisbe
  • 3,899
  • 8
  • 37
  • 45
gexicide
  • 38,535
  • 21
  • 92
  • 152
  • Right now My manifest file is like "Manifest-Version: 1.0" only. Still my application is doing fine. – Ashish Agarwal Jun 21 '12 at 13:52
  • of course, the mainfest is not necessary. It is simply able to carry additional information about the jar. – gexicide Jun 21 '12 at 13:53
  • I would like to draw a comparison here, Like in Mobile application, the application would not run without it, but that's not the case with Jar etc why? – Ashish Agarwal Jun 21 '12 at 13:55
  • 3
    Simple answer: It is not required by the java programming language :). What mobile platform are you talking about? – gexicide Jun 21 '12 at 13:57
  • Like for Andriod, we have to mention what kind of resource the application is intended to use, if we dont declare it, we will not be able to run the application on a mobile.I might be wrong but am just trying to draw some comparison. – Ashish Agarwal Jun 21 '12 at 13:59
  • what are the key benefits that we can draw with this? – Ashish Agarwal Jun 21 '12 at 14:00
  • 2
    not too many. Unless you need exactly one of the things described in the tutorial, you won't need to think about writing a manifest. In comparsion with android, it is much more lightweight, it contains only some **optional** configuration information, not much more. – gexicide Jun 21 '12 at 14:07