Java Classpath - Simple Question

Discussion in 'Java' started by RalphLeon, Aug 3, 2007.

  1. RalphLeon

    RalphLeon Guest

    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, Aug 3, 2007
    #1
    1. Advertising

  2. RalphLeon

    RalphLeon Guest

    RalphLeon, Aug 3, 2007
    #2
    1. Advertising

  3. RalphLeon wrote:
    > 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
    >


    The -jar option trumps the -classpath option. The -classpath is ignored.
    David Zimmerman, Aug 3, 2007
    #3
  4. David Zimmerman wrote:
    > RalphLeon wrote:
    >> 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
    >>

    >
    > 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.
    Mike Schilling, Aug 3, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Flip
    Replies:
    3
    Views:
    7,227
    Tony Morris
    Feb 9, 2004
  2. Gabe
    Replies:
    3
    Views:
    1,059
  3. cppaddict

    simple classpath question`

    cppaddict, Sep 24, 2006, in forum: Java
    Replies:
    2
    Views:
    367
    cppaddict
    Sep 24, 2006
  4. Replies:
    2
    Views:
    741
  5. Replies:
    2
    Views:
    1,089
    Mike Schilling
    Mar 2, 2008
Loading...

Share This Page