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 mainifest: Main-Class and Class-Path incompatible?

 
Dudley Dawson
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi-
I'm trying to package an application in a jar file which uses some external libs.
When I specify a Class-Path in the manifest, i get a NoClassDefFoundError exception for my Main-Class. When I remove the Class-Path header, of course, I get a NoClassDefFoundError exception for one of the classes I've imported in that main class.

It seems as though if I specify a Class-Path, ONLY the jars listed there are on the classpath - no longer the packages in the jar itself.
What am i doing wrong? (I tried adding "." to the Class-Path - still doesn't work)

FYI - my package is at the root of the jar:
com/mycompany/blah/blah
 
Campbell Ritchie
Sheriff
Posts: 48921
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please tell us some more details, eg your classpath, how you are setting it, and the contents of your manifest file.
 
Dudley Dawson
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Please tell us some more details, eg your classpath, how you are setting it, and the contents of your manifest file.


well, i'm not setting any specific classpath outside of the manifest. here it is:

I'm using the <manifest> element of ant's <jar> task to create it. 2 strange things i'm noticing are
1. the hard line breaks. Why would it do that? I'm specifying them all in one attribute of the <attibute> node:
2. the non-system friendly paths (slashes wrong way, etc)
I would imagine both of these would cause classpath problems, but, regardless; i would think it would be tbe IMPORTED classes that can't be found. Why would this have any effect on my main class?
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Class-Path entries are supposed to be relative to the location of the executable jar. Absolute locations are not permitted. So fix that up first.

(Yes, Main-Class and Class-Path are compatible, I just did that this afternoon.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic