Java Jar:manifest

Source: Internet
Author: User

Jar (Java Archive file, Java Archive), which is actually a zip file. It includes an optional Meta-inf directory. You can use the Jar command on the command line to generate a jar file, or you can use the Java.util.jar API to generate an archive file.

The role of the Meta-inf directory in JAR files: application configuration, extensions, ClassLoader, service delivery. In this directory, there are several main files (or directories):

MANIFEST. Mf

is a manifest file that defines extensions and package-related information

INDEX. LIST

It is part of the Jarindex implementation that the class loader uses to increase loading speed

X.sf

Signature file

X.dsa

Digital signatures

service/

The service provider configuration file is stored

For example:

1) Mysql-jdbc.jar

2) Servlet-api.jar

3) Activemq-all.jar

Main properties in MANIFEST

Let's take a look at the manifest.mf file in Mysql-jdbc.jar:

Manifest-version:1.0ant-version:apache Ant 1.8.2CREATED-BY:1.5.0_22-B03 (Sun Microsystems Inc.) Built-by:pb2userbundle-vendor:oracle Corporationbundle-classpath:. Bundle-version:5.1.31bundle-name:oracle Corporation ' JDBC Driver for mysqlbundle-manifestversion: 2bundle-symbolicname:com.mysql.jdbcexport-package:com.mysql.jdbc;version= "5.1.31"; uses:= "Com.mysql.jdbc. Log,javax.naming,javax.net.ssl,javax.xml.transform,org.xml.sax ", COM.M ysql.jdbc.jdbc2.optional;version=" 5.1.31 " ; uses:= "COM.MYSQL.JDBC,COM.M Ysql.jdbc.log,javax.naming,javax.sql,javax.transaction.xa", Com.mysql. Jdbc.log;version= "5.1.31", com.mysql.jdbc.profiler;version= "5.1.31"; US es:= "Com.mysql.jdbc", Com.mysql.jdbc.util; Version= "5.1.31"; uses:= "com. Mysql.jdbc.log", com.mysql.jdbc.exceptions;version= "5.1.31", Com.mysql. Jdbc.exceptions.jdbc4;version= "5.1.31", uses:= "Com.mysql.jdbc", Com.mys ql.jdbc.interceptors;version= "5.1.31"; Uses:= "Com.mysql.jdbc", com.mysq l.jdbc.integration.c3p0;version= "5.1.31", Com.mysql.jdbc.integratioN.J boss;version= "5.1.31", com.mysql.jdbc.configs;version= "5.1.31", Org.gjt. mm.mysql;version= "5.1.31" Import-package:javax.net,javax.net.ssl;version= "[1.0.1, 2.0.0)"; Resol Ution:=optional,javax.xml.parsers, JAVAX.XML.STREAM,JAVAX.XML.TRANSFO rm,javax.xml.transform.dom,javax.xml.transform.sax,javax.xml.transfor M.stax, Javax.xml.transform.stream,org.w3c.dom,org.xml.sax,org.xml.sax. Helpers;resolution:=optional,javax.naming, Javax.naming.spi,javax.sql, javax.transaction.xa;version= "[1.0.1, 2.0.0)"; resolution:=optional,c Om.mchange.v2.c3p0;version= "[0.9.1.2, 1.0.0)"; Resolution:=optional,or g.jboss.resource.adapter.jdbc;resolution:= Optional,org.jboss.resource. Adapter.jdbc.vendor;resolution:=optionalname:commonspecification-title: Jdbcspecification-version:4.0specification-vendor:oracle Corporationimplementation-title:mysql Connector Javaimplementation-version:5.1.31implementation-vendor-id:com.mysqlimplementation-vendor:oracle

the bundle-* in the above file is the content of OSGi and is not described here.

manifest-version: Is the version of the manifest file. is not a version of the jar package.

created-by: Jar Package creator.

Main-class: The main class in the jar package. Is the portal to the application, and this property is used only when the jar is a standalone Java application.

specification-* represents the descriptive information in the Java standard.

implementation-* represents that the jar package is an implementation of a Java standard.

The information in Mysql-jdbc.jar can be understood as: the implementation of the JDBC 4.0 standard in Mysql-jdbc-5.1.31.jar.

Similarly: The MANIFEST.MF in Servlet.jar are as follows:

Manifest-version:1.0ant-version:apache Ant 1.9.4CREATED-BY:1.5.0_22-B03 (Sun Microsystems Inc.) X-compile-source-jdk:1.5x-compile-target-jdk:1.5name:javax/servlet/specification-title:java API for Servletsspecification-version:2.5specification-vendor:sun Microsystems, Inc.implementation-title: Javax.servletimplementation-version:2.5.mr2implementation-vendor:apache Software Foundation

This means: the Servlet-api.jar implemented by ASF is the implementation of Servlets in Java standards.  

In addition, there is a main attribute sealed: This indicates whether the pacakage in the jar file is sealed.

The following is a list of two manifest files:

List one: The entire jar is sealed.

Manifest-version:1.0sealed:true

Listing II: The specified package is sealed:  

Manifest-version:1.0name:com/fjn/java/util/jar/sealed:true

in the jar package, only the Com/fjn/java/util/jar package is sealed.

List III:

Manifest-version:1.0sealed:truename:com/fjn/java/util/jar/sealed:false

the entire jar package, only the Com/fjn/java/util/jar package is not sealed, the rest are sealed.

Java Jar:manifest

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.