This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes jar file manifest Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "jar file manifest" Watch "jar file manifest" New topic

jar file manifest

Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
I have added the Main-Class heading to the manifest of my jar file. I am not using packages. When I try to run the jar file I get a NoClassDefFound error. I have verified that the class is in the jar. When I run the class outside of the jar it works. My classpath appears to be ok. Does anyone have any ideas on this?

Matthew Phillips
Jason Kretzer
Ranch Hand

Joined: May 31, 2001
Posts: 280
Well, there are a couple of things. First, in your manifest file, make sure you are using Main-Class: with a space after the colon. Make sure the class name on the Main-Class: line does not have the .class extension on it.
Next, when creating the jar make sure you are using the right command:
jar cvmf <name of manifest> <name of jar>.jar <all files to be included>
I apologize if this is too simplistic but I don't know your background.

Jason R. Kretzer<br />Software Engineer<br />System Administrator<br /><a href="" target="_blank" rel="nofollow"></a>
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
That seemed to do it. I had two spaces after the Main-Class heading. Thanks.
I agree. Here's the link:
subject: jar file manifest
It's not a secret anymore!