Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jar file manifest

 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Jason Kretzer
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
HTH,
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That seemed to do it. I had two spaces after the Main-Class heading. Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic