Re: Beginner Eclipse problem

From: Jason Dwyer (Jason.Dwye..edata.com.au)
Date: Tue Sep 28 2004 - 03:55:02 EDT

  • Next message: Denise Howard: "Re: Beginner Eclipse problem"

    hi denise,

    theres a number of ways to include the relevant jars into your
    classpath, its not an eclipse issue per se, as much as it is part and
    parcel of any java app which relies on multiple libraries

    probably the cleanest method will be to write an ant target which
    invokes java.

    another would be to write a short shell command which sets up a local
    variable to hold a list of jars.

    put this into a file called starter.sh: (or whatever)

    #!/bin/sh
    for i in $1/*.jar; do
    export MYPATH=$MYPATH:$i
    done

    java -cp $MYPATH $2

    ====cut here===
    ensure its executable (chmod 755 starter.sh)

    then invoke with 2 parameters:

    ./starter.sh <path_to_libs_dir> <fully_qualified_java_class>

    i've assumed your java libraries (jars) for the project are in one local
    directory, which you pass in as the first arg. if not, its a good
    practice: makes it easier to keep track of which libs ( and versions of
    libs) you are using.

    still, probably better to look into ant to manage all this for you.

    .. and while its possible to 'merge' the contents of jars into your own
    application's jar, you really dont want to be doing that...

    regards,

    j.dwyer
    redata software systems

    On Tue, 2004-09-28 at 12:20, Denise Howard wrote:
    > I hope this is a quick and easy one. I'm running Eclipse 3.0.1 on Mac OS X
    > 10.3.5. In Eclipse I can run my plain Java application to my heart's
    > content. It happens to use Apache Axis, so all those Axis jars are in the
    > build path.
    >
    > Then I use Eclipse to create a jar file for my application, and from the
    > command line I try to run the jar, and right off the bat I get a
    > "NoClassDefFoundError" for one of the Axis classes. Spelling out the
    > classpath (I copied and pasted from Eclipse's command line inspector so I
    > know they're all spelled and punctuated correctly) made no difference.
    >
    > What am I doing wrong? The Eclipse help system is wonderful but I couldn't
    > find quite the solution in it for this. Is there a way to have Eclipse
    > "copy" external jars (such as these Axis ones) into my application jar so
    > that I can hand it to someone who doesn't have Axis installed and it will
    > run for them (similar to the "merge" in Xcode)?
    >
    > Thanks--
    >
    > Denise
    >
    >
    >
    > ________________________________________________________________
    > This message could have been secured by PGP Universal. To secure
    > future messages from this sender, please click this link:
    >
    > https://keys.pgp.com/b/b.e?r=woproject-de..bjectstyle.org
    >



    This archive was generated by hypermail 2.0.0 : Tue Sep 28 2004 - 03:55:11 EDT