• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

executable jar exception

 
Sri Addanki
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Here's the exception when i run my jar file:

Failed to load Main-Class manifest attribute from
sri.jar


I don't think this is bcos of the classpath, any suggestions?
thanks,
sri
 
Ta Ri Ki Sun
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sri Addanki:
Hi,
Here's the exception when i run my jar file:

I don't think this is bcos of the classpath, any suggestions?
thanks,
sri

Does your manifest file include the main class?
 
Sri Addanki
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, my manifest file includes the main class file.
thanks,
sri
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does your manifest file look like?
 
Sri Addanki
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my Mainfest.MF looks like this:

Manifest-Version: 1.0
Main-Class: packagename.ui.mainclassname
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Main-Class: packagename.ui.mainclassname

Do you have a carriage return after this line?
 
Lin Feng
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That should be the case. The last line is omitted by jar. :-)
 
Ken Krebs
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change your main class specification to use slashes, not dots:
Main-Class: packagename/ui/mainclassname

kktec
SCJP 1.4
SCWCD
 
S. Ganapathy
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is real boon to have gurus like Eugene, Mark, Max ... here in this forum.
While I was trying to run jar file using "java -jar myjar.jar", I too got the same problem as that of Sri.
I tried this way and that way, and finally entered carriage return at the end of
"Main-Class: mypack.MainClass". It worked. I got surprised. Really I don't know the reason whats wrong in not having carriage return.
After I found answer from Eugene, I recalled the same mistake done by me.
Thankyou verymuch Eugene.
GVRao
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ken Krebs:
Change your main class specification to use slashes, not dots:
Main-Class: packagename/ui/mainclassname
kktec
SCJP 1.4
SCWCD

This is simply wrong info, -- it should be dot delimited.
Eugene.
 
Ken Krebs
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eugene,
My comment was :
Change your main class specification to use slashes, not dots:
Main-Class: packagename/ui/mainclassname
You said:
[QUOTE
This is simply wrong info, -- it should be dot delimited.

Are you sure this is wrong ? I have 2 examples on my website where this technique does work. I too had originally tried using dots and DID have a CR at the end of the line without success. Finally, in frustration, I searched Sun's site for the documentation on the JAR format specification of Main-Class. Here is what I found at JAR guide.

# attribute defined for stand-alone applications
This attribute is used by stand-alone applications that are bundled into executable jar files which can be invoked by the java runtime directly by running "java -jar x.jar".
* Main-Class :
The value of this attribute defines the relative path of the main application class which the launcher will load at startup time. The value must not have the .class extension appended to the class name.

Unfortunately, they don't show any examples. The words "relative path" is what led to me to try slashes. It worked. If you want to see for yourself, take a look at my Golf HandicapTracker Application. It contains the executable jar file for a small Swing app that has the following Manifest.mf file:

I have tried this on a several PC's running different flavors of Windoze. I used the same technique on another application with a more deeply nested Main class path name and it also works. If this method is wrong, why is it working ? Are not paths separated by slashes ?
If anybody can shed some light on this, I would really like to hear about it.
kktec
SCJP1.4 & SCWCD
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried this on a several PC's running different flavors of Windoze. I used the same technique on another application with a more deeply nested Main class path name and it also works. If this method is wrong, why is it working ? Are not paths separated by slashes ?
I tried both dot-delimited and slash-delimited entry for the "Main-Class" attribute, and actually both work! So please accept my apology, Ken, -- I was wrong. Just like you, I looked at the Sun's manifest file specification, but couldn't find anywhere the reference to how exactly the main class should be delimited. I posted a question in the Advanced Java forum, hopefully someone will help us resolve this issue.
Eugene.
[ April 25, 2003: Message edited by: Eugene Kononov ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic