• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

manifest.mf and runme.jar

 
Macy
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

My directory structure are the following (from root directory):
suncertify.db (all data classes)
suncertify.remote (all remote classes)
suncertify.gui (all client and server applications)
suncertify (contain a Start.class, the main program)

I created the manifest.mf in the root direstory:
Manifest-Version: 1.0
Main-Class: suncertify.Start

I created the runme.jar using:
jar cvmf runme.jar Manifest.mf -C suncertify .

When I try to run it:
java -jar runme.jar alone
I got an error "Failed to load Main-Class manifest attribute from runme.jar"

Can you help me figure what's wrong when I try to create executable jar? Thanks a lot!

Macy
 
Gary Hellman
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Macy,

Does your jar(oops - I mean manifest file) have a carriage control/line feed at the end?

see -
http://csdl.ics.hawaii.edu/~johnson/613f99/modules/04/jar-files.html

Hope this fixes it.
[ January 23, 2006: Message edited by: Gary Hellman ]
 
Surya De
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quite useful, Gary thanks.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11866
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Macy,

While I think Gary's comment might provide the answer you need, I just wanted to check something.
I created the runme.jar using:
jar cvmf runme.jar Manifest.mf -C suncertify .
The options to creating a jar file are position dependant. That is, you have specified "cvmf" which means that you wish to create a jar file, be verbose about it (show on screen all files being added), the next command line parameter will be the manifest, followed by the jar filename.

However you then contradict this by listing the jar filename first then the manifest.

To fix that problem, the command line you should be using should be:

jar cvmf Manifest.mf runme.jar -C suncertify .

Or:

jar cvfm runme.jar Manifest.mf -C suncertify .

I also think your paths are going to be wrong inside the jar file. You specified "-C suncertify" on your command line, which means that the paths will all start from within the suncertify directory. That is, instead of your jar file containing "suncertify/Start.class" the suncertify will be dropped, and Start.class will appear in the root directory.

You can check this by running "jar tvf runme.jar" and check whether you have "suncertify" in the paths.

To get around that problem, just drop the "-C suncertify" from the command line.

Regards, Andrew
 
Macy
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much!!! I don't have a carriage return at the end of the line.
It works fine now.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic