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

人盡茶涼 提交于 2019-12-04 15:42:43

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/11139643/what-is-use-of-manifest-mf-in-war-jar-ear

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!