wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes failed to load Main-Class manifest attribute?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "failed to load Main-Class manifest attribute??" Watch "failed to load Main-Class manifest attribute??" New topic
Author

failed to load Main-Class manifest attribute??

Praveen Kumar Jayaram
Ranch Hand

Joined: Jul 14, 2008
Posts: 56
Hi,

I have a swing application. When I run the app from IDE (Netbeans 6.0) it runs fine. If I try to run by clicking .JAR file, it will show "failed to load Main-Class manifest attribute from file.JAR".

I extracted the .JAR file and I found MANIFEST.MF didn't had Main-Class field. Even i added that field and zipped it and renamed back to file.JAR.
The above idea was suggested to someone in a forum. Even this didn't help.

Please give a suggestion. It is very urgent.

Regards,
Praveen


Praveen
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

Make sure there is a white space after Main-Class:
e.g. Main-Class: com.package.subpackage.MainClassName

I havent used Netbeans myself. However in Eclipse, I do get a prompt for the main class so I never have to worry about building the jar correctly.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Praveen Kumar Jayaram
Ranch Hand

Joined: Jul 14, 2008
Posts: 56
Thanks for the reply.

Yes I have a white space after Main-Class:
Even Netbeans creates the JAR file automatically. It was working before.
But now it runs only from IDE and not by clicking the JAR

Any help?


Regards,
Praveen
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

Originally posted by Praveen Kumar Jayaram:

Even Netbeans creates the JAR file automatically. It was working before.
But now it runs only from IDE and not by clicking the JAR


You said earlier that the manifest file did not have a Main-Class entry. Obviously the jar is not being built properly. Please check why that is the case.

When you run it from the IDE, I dont think it is running from the jar but from your generated class files.

Cant help beyond this. Sorry.
Saurabh Gangarde
Greenhorn

Joined: Jun 06, 2008
Posts: 10
Hi I have got all things correct but still getting th same error..
Pluse I got to keep some dlls in my package so can anyone tell me how to do that.. ?
I dont use any IDE...
[ August 21, 2008: Message edited by: Saurabh Gangarde ]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39409
    
  28
Saurabh Gangarde, please don't add what is actually a new question (about dlls) to somebody else's thread; it's called hijacking and it can lose the original poster any control over their thread.

Praveen Kumar: have you been through the Java Tutorials? You ought to bookmark that link (or similar). Look for "deployment" and it tells you all about jars.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: failed to load Main-Class manifest attribute??