JAR file runtime error caused by CLASSPATH

Discussion in 'Java' started by PhilBray, Sep 19, 2006.

  1. PhilBray

    PhilBray Guest

    Hello,

    I am having an absolute nightmare trying to get a JAR file that I built
    within Eclipse to run via a double click windows environment. I know
    that the problem relates back to my CLASSPATH but I am having no luck
    at all resolving the issue.

    I have about 15 external JAR files that I need to reference from my JAR
    and therefore I need to setup a CLASSPATH that will point to all the
    external JAR's. I have tried building a manifest file by hand and I
    have tried all the CLASSPATH configuration settings that I can find.
    Everytime I keep getting a java.lang.NoClassDefFoundError after running
    the following command:

    java -jar myjarfile.jar

    The NoClassDefFoundError relates to a class that exists within one of
    my external JAR files. When I use Eclipse to create the JAR it does not
    seem to add any 'Class-Path' attribute to it and when I add it myself
    Eclipse complains about invalid header sections e.g.

    Manifest-Version: 1.0
    Class-Path: lib\external_jar_one.jar
    Main-Class: com.myapp.mainclass

    Does anybody have an easy step by step approach that I can follow that
    will get me where I want to be? I will be forever greatful.

    Many thanks in advance,

    Phil
    PhilBray, Sep 19, 2006
    #1
    1. Advertising

  2. PhilBray

    hiwa Guest

    PhilBray wrote:
    > Hello,
    >
    > I am having an absolute nightmare trying to get a JAR file that I built
    > within Eclipse to run via a double click windows environment. I know
    > that the problem relates back to my CLASSPATH but I am having no luck
    > at all resolving the issue.
    >
    > I have about 15 external JAR files that I need to reference from my JAR
    > and therefore I need to setup a CLASSPATH that will point to all the
    > external JAR's. I have tried building a manifest file by hand and I
    > have tried all the CLASSPATH configuration settings that I can find.
    > Everytime I keep getting a java.lang.NoClassDefFoundError after running
    > the following command:
    >
    > java -jar myjarfile.jar
    >
    > The NoClassDefFoundError relates to a class that exists within one of
    > my external JAR files. When I use Eclipse to create the JAR it does not
    > seem to add any 'Class-Path' attribute to it and when I add it myself
    > Eclipse complains about invalid header sections e.g.
    >
    > Manifest-Version: 1.0
    > Class-Path: lib\external_jar_one.jar
    > Main-Class: com.myapp.mainclass
    >
    > Does anybody have an easy step by step approach that I can follow that
    > will get me where I want to be? I will be forever greatful.
    >
    > Many thanks in advance,
    >
    > Phil

    If your current directory is PhilB

    C:\PhilB> java -jar myjarfile.jar

    Then your myjarfile.jar internal structure should be:

    comp\myapp\mainclass.class
    ---and other classes honoring original package structures as above.

    And your external_jar_one.jar should be stored as:

    C:\PhilB\lib\external_jar_one.jar
    hiwa, Sep 20, 2006
    #2
    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. Gabe
    Replies:
    3
    Views:
    1,073
  2. Arnold Peters
    Replies:
    0
    Views:
    568
    Arnold Peters
    Jan 5, 2005
  3. cppaddict
    Replies:
    7
    Views:
    365
    cppaddict
    Jul 14, 2004
  4. Replies:
    2
    Views:
    1,105
    Mike Schilling
    Mar 2, 2008
  5. mike
    Replies:
    7
    Views:
    2,023
    Lothar Kimmeringer
    Apr 20, 2010
Loading...

Share This Page