About jar file

J

Jack Dowson

Hello everybody:
I have a problem when I excuted a jar file.

My manifest.mf if as follow:
Manifest-Version: 1.0
Created-By: 1.5.0_02 (Sun Microsystems Inc.)
Main-Class: WebBrowser
(My programe can run when I use command "java WebBrowser")

When I used "jar cfm WebBrowser.jar MANIFEST.MF *.class" to create
WebBrowser.jar and then excuted it,my jvm poped out a message:
"Failed to load Main-class manifest attribute form F:\java\Small
system\exploer\WebBrowser.jar"

I've set the right classpath,why?
Any help will be greatly appreciated!

Dowson
 
J

Jack Dowson

Andrew Thompson 写é“:
Does this file end in a blank line?
It can cause problems if the manifest.mf does not
end with a single (entirely) blank line.

Thank you so much!
It works when I add an entirely single blank line at the end.
Could you tell me why?

Dowson.
 
A

Andrew Thompson

Jack said:
Andrew Thompson 写é“: ...
It works when I add an entirely single blank line at the end.
Could you tell me why?

Not very well.

AFAIU, the tool that reads it, is designed to only
parse the information up to the 'next from last' line.
Bug reports have been raised, but Sun marks them
as 'not a bug'. I have never met any developer who
agrees with Sun's assessment.

Glad you got it sorted.

Oh, and before I forget. Ant will typically generate
a valid manifest file. I highly recommend doing the
build with the 'tool that gets it right', rather than
creating manifest files 'by hand' (making them in
a text editor).

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1
 
J

Jack Dowson

Andrew Thompson 写é“:
AFAIU, the tool that reads it, is designed to only
parse the information up to the 'next from last' line.
Bug reports have been raised, but Sun marks them
as 'not a bug'. I have never met any developer who
agrees with Sun's assessment.

Thank You!
Only to parse the information up to the 'next from last' line is really
a stupid design.

Dowson.
 
M

Mike Schilling

Jack Dowson said:
Andrew Thompson ??:

Thank You!
Only to parse the information up to the 'next from last' line is really a
stupid design.

The manifest parser isn't quite that stupid. It insists that every line be
terminated by a valid line terminator (LF/CRLF/CR). If the last line isn't
terminated that way, it ignores it. Since some editors don't terminate the
last line of a file that way, the safest thing to do is insert a blank line
at the bottom, guaranteeing that the previous (non-blank) line gets
terminated correctly. Still not good behavior, I'll admit, but
kinda/sorta justified by the manifest spec at
http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Manifest-Overview.

At least Sun finally defined manifests as UTF-8. The manifest-processing
code in java.util.jar used to silently throw away the high byte of every
character.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top