Java Jar: Manifest, javajarmanifest

Source: Internet
Author: User

Java Jar: Manifest, javajarmanifest

 

Jar (Java Archive File, java Archive File), which is actually a zip File. It includes an optional META-INF directory. You can use the jar command in the command line to generate a jar file, or use java. util. jar API to generate an archive file.

The role of the META-INF directory in the Jar file: application configuration, extension, Class Loader, provide services. In this directory, there are mainly the following files (or directories ):

 

MANIFEST. MF

Is a configuration file that defines extensions and package-related information.

INDEX. LIST

It is part of the implementation of JarIndex, and the class loader can use it to increase the loading speed.

X. SF

Signature File

X. DSA

Digital Signature

Service/

Stores the service provider configuration file.

 

For example:

1) mysql-jdbc.jar

 

 

2) servlet-api.jar

 

 

3) activemq-all.jar

 

 

 

 

 

Main attributes in MANIFEST

 

Let's take a look at the MANIFEST. MF file in the 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

Bundle-* in the above file is OSGi content, which is not described here.

 

Manifest-Version: The version of the configuration file. It is not the version of the jar package.

Created-: Jar package creator.

Main-Class: Main class in the jar package. Is the entry of the application. This attribute is only used when jar is used as an independent java application.

 

Specification -*Represents the description in the Java standard.

Implementation -*Indicates that the Jar package is a Java standard implementation.

 

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

 

Similarly, MANIFEST. MF in servlet. jar is 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

The servlet-api.jar implemented by ASF is the implementation of Servlets in java standard.

In addition, Sealed indicates whether the pacakage in the jar file is Sealed.

 

The following are two configuration files:

Listing 1: The entire jar is sealed.

Manifest-Version: 1.0Sealed: true

 

List 2: 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.

 

Listing 3:

Manifest-Version: 1.0Sealed: trueName: com/fjn/java/util/jar/Sealed: false

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

 

Related Article

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.