Help with executing a jar file

Discussion in 'Java' started by Bryan, Dec 15, 2006.

  1. Bryan

    Bryan Guest

    Hello all,

    I'm having trouble executing a jar file I created using Eclipse. I
    have two projects set up in Eclipse... one with all the main source
    code (no Main classes) and another with a main class that utilizes code
    from the other project. I created a jar of the first project and added
    the jar to the build path of the second project and I can run the Main
    class in the second project no problem. I then created a jar file of
    the second project and included the Main class in the manifest. When I
    try to execute this jar file from the command line I get the following
    error:

    % java -cp SourceCode.jar -jar Executable.jar
    Exception in thread "main" java.lang.NoClassDefFoundError:
    /path/to/some/package/class

    Both the source jar and the executable jar are in the current working
    directory. Any clues as to why this isn't working?

    Thanks!
     
    Bryan, Dec 15, 2006
    #1
    1. Advertising

  2. Bryan wrote:
    ....
    > % java -cp SourceCode.jar -jar Executable.jar


    Note the -cp option is ignored when the -jar
    option is specified.

    Andrew T.
     
    Andrew Thompson, Dec 15, 2006
    #2
    1. Advertising

  3. Bryan

    Bryan Guest

    So how do I tell it to include SourceCode.jar in the classpath so
    Executable.jar has access to it?

    On Dec 15, 11:22 am, "Andrew Thompson" <> wrote:
    > Bryan wrote:...
    >
    > > % java -cp SourceCode.jar -jar Executable.jarNote the -cp option is ignored when the -jar

    > option is specified.
    >
    > Andrew T.
     
    Bryan, Dec 15, 2006
    #3
  4. Bryan wrote:
    > So how do I tell it to include SourceCode.jar in the classpath so
    > Executable.jar has access to it?
    >
    > On Dec 15, 11:22 am, "Andrew Thompson" <> wrote:
    >> Bryan wrote:...
    >>
    >>> % java -cp SourceCode.jar -jar Executable.jarNote the -cp option is ignored when the -jar

    >> option is specified.
    >>
    >> Andrew T.

    >


    You have to specify it in the manifest file.

    http://rabbitbrush.frazmtn.com/classpath.html#jar

    --

    Knute Johnson
    email s/nospam/knute/
     
    Knute Johnson, Dec 15, 2006
    #4
  5. Bryan

    Bryan Guest

    Thanks, that worked great!!

    On Dec 15, 12:29 pm, Knute Johnson <>
    wrote:
    > Bryan wrote:
    > > So how do I tell it to include SourceCode.jar in the classpath so
    > > Executable.jar has access to it?

    >
    > > On Dec 15, 11:22 am, "Andrew Thompson" <> wrote:
    > >> Bryan wrote:...

    >
    > >>> % java -cp SourceCode.jar -jar Executable.jarNote the -cp option is ignored when the -jar
    > >> option is specified.

    >
    > >> Andrew T.You have to specify it in the manifest file.

    >
    > http://rabbitbrush.frazmtn.com/classpath.html#jar
    >
    > --
    >
    > Knute Johnson
    > email s/nospam/knute/
     
    Bryan, Dec 15, 2006
    #5
    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. Arnold Peters
    Replies:
    0
    Views:
    582
    Arnold Peters
    Jan 5, 2005
  2. muttley
    Replies:
    0
    Views:
    2,726
    muttley
    Oct 20, 2005
  3. cyberco
    Replies:
    4
    Views:
    3,768
    Roedy Green
    Feb 14, 2006
  4. Arnold Peters
    Replies:
    0
    Views:
    666
    Arnold Peters
    Jan 5, 2005
  5. O.B.
    Replies:
    0
    Views:
    477
Loading...

Share This Page