my dog learned polymorphism
The moose likes Java in General and the fly likes JAR classpath insanity 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 classpath insanity" Watch "JAR classpath insanity" New topic

JAR classpath insanity

Lucian Smith

Joined: Mar 04, 2006
Posts: 4
My mind is gone. Here is the situation: Using Eclipse I generate a jar file containing the following structure:


Okay, I made a manifest that specified an entry point for my app (this part works). What doesn't work is that I'm getting a NoClassDefFoundError NO MATTER WHAT I DO. I tried specifing like 1000 varieties of Class-Path: in the manifest, with paths like libs/commons-configuration-1.4/commons-configuration-1.4.jar or ./libs or even putting the jars right in the libs directory or even in the same directory at the main class.

I run the jar with java -jar JarName.jar

but I also put in all sorts of -classpath specifications...

Basically no matter what I do, nothing is working.

All the library JARS I have in my main jar. All I need is for my main class (in the jar) to have the library jars (also in the jar) in its classpath.

Thank you everyone!!!
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

All the library JARS I have in my main jar.
You mean inside the main jar? Then that's your problem. Don't do that, standard classloaders won't find jars inside jars. Put them in the same directory as your executable jar. The path you put in the manifest for a library jar is relative to the executable jar.
I agree. Here's the link:
subject: JAR classpath insanity
It's not a secret anymore!