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?

4

2 Answers 2

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!

1
  • I've added a folder META-INF/MANIFEST.MF, it is ignoring this file in the output, and still no manifest attribute? Jan 20, 2014 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

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. Apr 10, 2021 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.