Automatically Creating Manifest File with Eclipse for JAR Files

后端 未结 8 1263
野性不改
野性不改 2021-01-04 01:50

How can I create a Manifest file for a group of JAR file I have already created.

I used Eclipse to create my JAR file.

Is there any better way o

8条回答
  •  暖寄归人
    2021-01-04 02:23

    I just ran into this problem today.

    Yes, Eclipse will create the Manifest for you, but it's really a joke.

    It only includes the line Manifest-Version: 1.0. I have not figured out how to make it add my Main class, so I created my own MANIFEST.MF file, added it to my project main directory (not src and not lib). Then, when I go to Export > JAR File, hit Next all the way to the end (do not hit Finish too early) and click the option to select manifest from project. Select the Manifest file you just added to your project. Make sure the Manifest has the path to your Main class (e.g. com.company etc). For example this is how a basic Manifest file would look like:

    Manifest-Version: 1.0
    Created-By: 1.6.0 (Sun Microsystems Inc.)
    Main-Class: MyPackage.MyClass
    

    I tried @Michael's method but I ended up with no class files left in my JAR and only Manifest files.. oh well. My above method works well.

提交回复
热议问题