• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jar problem

 
gidones hamami
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Regards,
Gidone
 
Michael Morris
Ranch Hand
Posts: 3451
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic