7

I would like make an executable jar archive with eclipse. So into my project I created file src/META-INF/MANIFEST.MF :

Manifest-Version: 1.0
Main-Class: MainClass
Class-Path: .

But when I export my java eclipse project eclipse warn me with following message:

"JAR export finished with warnings. See details for additional information. myproject/src/META-INF/MANIFEST.MF was replaced by the generated MANIFEST.MF and is no longer in the JAR."

Anyone know how I can avoid this when I export my project in eclipse?

Eugen Labun
  • 2,561
  • 1
  • 22
  • 18
freedev
  • 25,946
  • 8
  • 108
  • 125

2 Answers2

11

While exporting the jar, select the option to use existing manifest and browse to the manifest file of your project. The generated jar will have that manifest file now.

Using existing manifest http://img46.imageshack.us/img46/6752/export.png

Abhinav Sarkar
  • 23,534
  • 11
  • 81
  • 97
  • This no longer works in current Eclipse, as of 2015-09-17. – sventechie Sep 17 '15 at 20:04
  • @sventechie: The Eclipse Wizard can do a few simple things. If you need something more complex, use the command line and Ant or Maven. – Aaron Digulla Sep 21 '15 at 13:20
  • @AaronDigulla This is a very common, simple need for Java developers and Eclipse can no longer do it. Not only will it not generate it for you but it won't allow you to make a custom manifest either -- it will always be overwritten. Being dismissive is not helpful. – sventechie Sep 21 '15 at 16:24
  • @sventechie Since IBM left, development speed of core Eclipse has slowed to glacial speeds. You can try to open a bug but my gut feeling is that it will have 3+ years before anyone can look at it. Sorry. – Aaron Digulla Sep 23 '15 at 07:40
2

Using Oxygen (Release 4.7.0), I was able to do this successfully. The confusing part is that on the JAR File Specification page of the JAR Export wizard, both the Next and Finish buttons are active. So if you don't notice that and just click Finish, you'll end up with a warning (and the generated manifest). To use your own, click Next instead (once for JAR Packaging Options, and again for JAR Manifest Specification).

John Sichi
  • 166
  • 1
  • 4