Every year or so I do a project with java.... and every year I come
into the same problem.
I have a jar file I want to use with my application, say Foo.jar in
the "lib" directory.
My application is a jar file, say Bar.jar put together by ant.
I want to use some utility in Foo.jar
I call:
$ java -classpath .:lib/Foo.jar -jar Bar.jar
and I get a "Exception in thread "main"
java.lang.NoClassDefFoundError: " related to the class I want in
Foo...
In my main file I did a
"include Foo.*;"
and everything *compiles* just fine.... I can post specific code if it
will help.... I figure I am just forgetting something silly...
At Your Mercy,
Ralph
RalphLeon - 03 Aug 2007 18:05 GMT
For the love of god I just figured it out:
In the jar's manifest file add:
Class-Path: jar1-name jar2-name directory-name/jar3-name
For more info:
http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html
Why is this process so confusing!?
David Zimmerman - 03 Aug 2007 19:24 GMT
> Every year or so I do a project with java.... and every year I come
> into the same problem.
[quoted text clipped - 8 lines]
> I call:
> $ java -classpath .:lib/Foo.jar -jar Bar.jar
The -jar option trumps the -classpath option. The -classpath is ignored.
Mike Schilling - 03 Aug 2007 19:56 GMT
>> Every year or so I do a project with java.... and every year I come
>> into the same problem.
[quoted text clipped - 11 lines]
> The -jar option trumps the -classpath option. The -classpath is
> ignored.
Though no error (or even warning) saying "-classpath is not valid here" is
produced. That would make things far too straightforward.