8
jar cvef Main.jar Main *

added manifest
adding: DrawPane.class(in = 344) (out= 257)(deflated 25%)
adding: DrawPane.java(in = 306) (out= 175)(deflated 42%)
adding: main(in = 9038) (out= 8275)(deflated 8%)
adding: Main.class(in = 868) (out= 544)(deflated 37%)
adding: Main.java(in = 507) (out= 260)(deflated 48%)
adding: Manifest.txt(in = 18) (out= 18)(deflated 0%)
adding: src/(in = 0) (out= 0)(stored 0%)
adding: src/icon.png(in = 1163) (out= 1168)(deflated 0%)
adding: src/Thumbs.db(in = 3584) (out= 1038)(deflated 71%)

jar file created, then:

java -jar Main.jar

I get an error:

no main manifest attribute, in Main.jar

what I'am doing wrong?

yeah its me
  • 1,131
  • 4
  • 18
  • 27
  • possible duplicate of [Can't execute jar- file: "no main manifest attribute"](http://stackoverflow.com/questions/9689793/cant-execute-jar-file-no-main-manifest-attribute) – Sotirios Delimanolis Jan 20 '14 at 17:04
  • but I'am doing it all right, can't understand why can't find the Manifest attribute? look at the output... – yeah its me Jan 20 '14 at 17:05
  • this is not a duplicate, please can you look at my code and give me an advice on what is not right? because I get a message that "added manifest" but still doesn't find it on executing... – yeah its me Jan 20 '14 at 17:12
  • http://stackoverflow.com/questions/9689793/cant-execute-jar-file-no-main-manifest-attribute This is exactly what you are looking for. – Omkar VASHISHTHA Jun 20 '14 at 09:14

2 Answers2

6

As per this tutorial your manifest file should have relative path META-INF/MANIFEST.MF. It doesn't look like you added your own manifest there. The jar command adds a default manifest, that's why it says 'manifest added'.

EDIT: As per the next page in the tutorial, the basic syntax to add content to the manifest file is the following:

jar cfm jar-file manifest-addition input-file(s)

I recommend to read the first few section of the tutorial and I'm sure you'll get the result you want!

Giovanni Botta
  • 9,626
  • 5
  • 51
  • 94
  • I've added a folder META-INF/MANIFEST.MF, it is ignoring this file in the output, and still no manifest attribute? – yeah its me Jan 20 '14 at 17:30
2

make sure to write 1 space after ":" and new line after class name and save it that way. jar tool syntax:

 jar -cvmf manifest.txt appname.jar ClassName.class

after running tool , run jar file with

java -jar appname.jar

Content of manifest.txt file

Main-Class:(1space)ClassName(press enter for new line)

Hope it helps

Pradida
  • 21
  • 1
  • I find it funny how the manifest needs to have a new line at the end. Recently also noticed that the javac tool can't read UTF16LE BOM. – Nikola Petrovic Apr 10 '21 at 14:36