Java – create meta-inf / services folder in eclipse

I tried to create an extensible application in Java and chose to use SPI According to this tutorial, I'm paying attention. I should create a specific file in meta inf / services in my jar, but I don't know how

Thanks for your help.

Solution

Since the tutorial is instructing you to create it manually instead of using ant or Maven or other build tools, you only need to create a folder named meta-inf at the root level, which contains a folder named services and a folder named manifest MF file

I don't know how to plan to execute your jar file. Now you can put this line in your manifest In MF:

Manifest-Version: 1.0

For your services folder, you need to create a folder called com example. dictionary. spi. Dictionary file, which contains the following line, as described in this tutorial:

com.example.dictionary.GeneralDictionary

FYI - meta - inf is an internal Java meta - directory In general, you want to rely on your wrapper tools (such as ant or Maven) to build the contents of the meta - inf folder instead of doing it yourself

You can see details about the contents of the meta inf folder here:

The following files/directories in the Meta-INF directory are recognized and interpreted by the Java 2 Platform to configure applications,extensions,class loaders and services:

    MANIFEST.MF

The manifest file that is used to define extension and package related data.

    INDEX.LIST

This file is generated by the new "-i" option of the jar tool,which contains location information for packages defined in an application or extension.  It is part of the JarIndex implementation and used by class loaders to speed up their class loading process.

    x.SF

The signature file for the JAR file.  'x' stands for the base file name.

    x.DSA

The signature block file associated with the signature file with the same base file name. This file stores the digital signature of the corresponding signature file.

    services/
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>