This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes manifest.mf and runme.jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "manifest.mf and runme.jar" Watch "manifest.mf and runme.jar" New topic
Author

manifest.mf and runme.jar

Macy
Greenhorn

Joined: Oct 28, 2005
Posts: 26
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


Macy Wong<br />SCJP 1.4 & 5.0, SCJD, SCWCD, SCBCD, Oracle PL/SQL OCA
Gary Hellman
Greenhorn

Joined: Sep 24, 2005
Posts: 11
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 ]

Thanks<br />Gary<br />SCJP 1.4
Surya De
Greenhorn

Joined: Nov 06, 2005
Posts: 28
Quite useful, Gary thanks.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

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


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Macy
Greenhorn

Joined: Oct 28, 2005
Posts: 26
Thank you so much!!! I don't have a carriage return at the end of the line.
It works fine now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: manifest.mf and runme.jar
 
Similar Threads
Creating the .jar file
assignment JAR problem
help with jar utility
Problems creating a jar
Unable to create jar with specified manifest.mf