aspose file tools*
The moose likes Java in General and the fly likes jar mainifest: Main-Class and Class-Path incompatible? 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 mainifest: Main-Class and Class-Path incompatible?" Watch "jar mainifest: Main-Class and Class-Path incompatible?" New topic
Author

jar mainifest: Main-Class and Class-Path incompatible?

Dudley Dawson
Ranch Hand

Joined: Dec 14, 2004
Posts: 57
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

Joined: Oct 13, 2005
Posts: 38897
    
  23
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

Joined: Dec 14, 2004
Posts: 57
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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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.)
 
wood burning stoves
 
subject: jar mainifest: Main-Class and Class-Path incompatible?