File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes jar problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "jar problem" Watch "jar problem" New topic

jar problem

gidones hamami

Joined: Feb 12, 2003
Posts: 3
Hi everybody!
If anyone can please help me, I want to run a jar on windows 2000 command prompt:
�java �jar jarName.jar�
I am getting this error message:
�Failed to load Main-Class mainfest attribute from jarName.jar�
Please give me some advises
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi gidones,

�Failed to load Main-Class mainfest attribute from jarName.jar�

That probably means that you don't have a main class declared in the manifest. Inside the jar file (which is only a zip file with a different extension) there is a directory META-INF and in that directory, there should be a file named MANIFEST.MF. In that file are contained attributes for the jar file. For a jar to be executable, there must be Main-Class attribute. Here is an example of what a MANIFEST.MF file might look like:

That would work if MyClass were in the default (undeclared) package. If it were in say myPackage.main then our manifest would look like this:

Hope this helps,
Michael Morris

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
I agree. Here's the link:
subject: jar problem
It's not a secret anymore!