Making our way to the jars...

Discussion in 'Java' started by Rico, Feb 27, 2005.

  1. Rico

    Rico Guest

    D:\program files\Eclipse\workspace\FolderMonitor>java -cp D:\activation.jar;D:\m
    ail.jar;D:\log4j-1.2.8.jar -jar folder*


    Am I doing something wrong with the above command?
    The 3 jars are in D:\ (of course) but I get NoClassDefFoundError:
    javax/mail/Address

    I started off with them all in the same folder as the jar I'm trying to
    run. That also gave NoClassDefFoundError

    When I move the jars to jre\lib\ext, things work fine.

    I came across Invoker on Dawid Weiss's website and I do this:

    java -jar Invoker.jar -cpalljars .\ -cpdir .\ <fully qualified classname>

    Things work fine.

    Why would both using the absolute path to the jars and placing them
    in the current working directory still cause NoClassDefFoundError?

    Rico.
     
    Rico, Feb 27, 2005
    #1
    1. Advertising

  2. Rico

    Oscar kind Guest

    Rico <> wrote:
    > D:\program files\Eclipse\workspace\FolderMonitor>java -cp D:\activation.jar;D:\m
    > ail.jar;D:\log4j-1.2.8.jar -jar folder*
    >
    >
    > Am I doing something wrong with the above command?
    > The 3 jars are in D:\ (of course) but I get NoClassDefFoundError:
    > javax/mail/Address


    Yes: if the -jar switch is used, the classpath switches (-classpath and
    -cp) are ignored. So is the CLASSPATH variable.

    This is documented in the manual, right after the most elaborate
    explanation of the -jar switch (not the first). So if you read the manual
    instead of just skimming it, it's unfortunately likely that you missed
    it.

    There is a solution however: If you know the location of activation.jar
    and mail.jar relative to your own .jar file, you can make it work by
    adding one or more "Class-Path:" headers to the manifest.

    See here for more information:

    http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Main Attributes


    --
    Oscar Kind http://home.hccnet.nl/okind/
    Software Developer for contact information, see website

    PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
     
    Oscar kind, Feb 28, 2005
    #2
    1. Advertising

  3. Rico

    Rico Guest

    On Mon, 28 Feb 2005 19:47:47 +0100, Oscar kind wrote:
    > Yes: if the -jar switch is used, the classpath switches (-classpath and
    > -cp) are ignored. So is the CLASSPATH variable.
    >
    > This is documented in the manual, right after the most elaborate
    > explanation of the -jar switch (not the first). So if you read the
    > manual instead of just skimming it, it's unfortunately likely that you
    > missed it.
    >
    > There is a solution however: If you know the location of activation.jar
    > and mail.jar relative to your own .jar file, you can make it work by
    > adding one or more "Class-Path:" headers to the manifest.
    >
    > See here for more information:
    >
    > http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Main Attributes


    All right. Thanks a lot for the pointers and the clarification.
    I'll stick with Invoker.jar which works like a charm for me for now.

    Rico.
     
    Rico, Mar 1, 2005
    #3
    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. Ike
    Replies:
    6
    Views:
    1,100
    Andrew Thompson
    Sep 24, 2004
  2. Replies:
    5
    Views:
    9,118
  3. JavaEnquirer
    Replies:
    2
    Views:
    550
    JavaEnquirer
    Feb 22, 2006
  4. hynespm
    Replies:
    0
    Views:
    328
    hynespm
    Jun 8, 2007
  5. Ulf Meinhardt
    Replies:
    2
    Views:
    1,436
Loading...

Share This Page