Newbie question

Discussion in 'Java' started by Daniel Pitts, Feb 13, 2007.

  1. Daniel Pitts

    Daniel Pitts Guest

    On Feb 12, 8:02 pm, Riley Rook <> wrote:
    > If I have Classes.jar, and I want to use it in a project, where do I put
    > the file? I have the file in my SDK as well as the directory of the
    > project. I've tried:
    >
    > import Classes.jar;
    > import Classes;
    > package Classes;
    > package Classes.jar;
    >
    > plus or minus a few variations. Can anyone help me with the syntax,
    > point me in the right direction for the location of the jar file?



    Classes.jar should contain a bunch of .class files in a package
    structure.

    The name of the jar file has nothing to do with the name of the
    package.

    Say that, in MyClasses.jar, I have (at least) the following files:

    mypackage/MyFirstClass.class
    mypackage/MySecondClass.class

    Them I would use
    import mypackage.MyFirstClass;

    public class YetAnotherClass {
    MyFirstClass first = new MyFirstClass();
    //...
    }

    Hope this helps...
    Daniel.
     
    Daniel Pitts, Feb 13, 2007
    #1
    1. Advertising

  2. Daniel Pitts

    Jeff Guest

    On Feb 12, 8:14 pm, "Daniel Pitts" <>
    wrote:
    > On Feb 12, 8:02 pm, Riley Rook <> wrote:
    >
    > > If I have Classes.jar, and I want to use it in a project, where do I put
    > > the file? I have the file in my SDK as well as the directory of the
    > > project. I've tried:

    >
    > > import Classes.jar;
    > > import Classes;
    > > package Classes;
    > > package Classes.jar;

    >
    > > plus or minus a few variations. Can anyone help me with the syntax,
    > > point me in the right direction for the location of the jar file?

    >
    > Classes.jar should contain a bunch of .class files in a package
    > structure.
    >
    > The name of the jar file has nothing to do with the name of the
    > package.
    >
    > Say that, in MyClasses.jar, I have (at least) the following files:
    >
    > mypackage/MyFirstClass.class
    > mypackage/MySecondClass.class
    >
    > Them I would use
    > import mypackage.MyFirstClass;
    >
    > public class YetAnotherClass {
    > MyFirstClass first = new MyFirstClass();
    > //...
    >
    > }
    >
    > Hope this helps...
    > Daniel.



    Would add - the jar file needs to be in the classpath, or you can
    install it as a library for your project. How you do this is somewhat
    dependent on your development platform. I would, in Netbeans, open the
    project tree, right click the libraries icon, choose add library, and
    browse to wherever your classes.jar happens to be. Now the classes
    will be able to be imported using the code posted before.
    /js
     
    Jeff, Feb 13, 2007
    #2
    1. Advertising

  3. Daniel Pitts

    Riley Rook Guest

    If I have Classes.jar, and I want to use it in a project, where do I put
    the file? I have the file in my SDK as well as the directory of the
    project. I've tried:

    import Classes.jar;
    import Classes;
    package Classes;
    package Classes.jar;

    plus or minus a few variations. Can anyone help me with the syntax,
    point me in the right direction for the location of the jar file?
     
    Riley Rook, Feb 13, 2007
    #3
  4. Daniel Pitts

    F Marker Guest

    Jeff wrote:
    > On Feb 12, 8:14 pm, "Daniel Pitts" <>
    > wrote:
    >> On Feb 12, 8:02 pm, Riley Rook <> wrote:
    >>
    >>> If I have Classes.jar, and I want to use it in a project, where do I put
    >>> the file? I have the file in my SDK as well as the directory of the
    >>> project. I've tried:
    >>> import Classes.jar;
    >>> import Classes;
    >>> package Classes;
    >>> package Classes.jar;
    >>> plus or minus a few variations. Can anyone help me with the syntax,
    >>> point me in the right direction for the location of the jar file?

    >> Classes.jar should contain a bunch of .class files in a package
    >> structure.
    >>
    >> The name of the jar file has nothing to do with the name of the
    >> package.
    >>
    >> Say that, in MyClasses.jar, I have (at least) the following files:
    >>
    >> mypackage/MyFirstClass.class
    >> mypackage/MySecondClass.class
    >>
    >> Them I would use
    >> import mypackage.MyFirstClass;
    >>
    >> public class YetAnotherClass {
    >> MyFirstClass first = new MyFirstClass();
    >> //...
    >>
    >> }
    >>
    >> Hope this helps...
    >> Daniel.

    >
    >
    > Would add - the jar file needs to be in the classpath, or you can
    > install it as a library for your project. How you do this is somewhat
    > dependent on your development platform. I would, in Netbeans, open the
    > project tree, right click the libraries icon, choose add library, and
    > browse to wherever your classes.jar happens to be. Now the classes
    > will be able to be imported using the code posted before.
    > /js
    >


    I wasn't using netbeans before, man, that sure is a whole lot easier.
    Seems to be working now, thanks alot to the both of you!
     
    F Marker, Feb 13, 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. Jerry C.
    Replies:
    8
    Views:
    277
    Uri Guttman
    Nov 23, 2003
  2. Kruno Saho
    Replies:
    0
    Views:
    168
    Kruno Saho
    Apr 7, 2013
  3. Dave Angel
    Replies:
    0
    Views:
    145
    Dave Angel
    Apr 7, 2013
  4. rusi
    Replies:
    0
    Views:
    133
  5. Miki Tebeka
    Replies:
    0
    Views:
    95
    Miki Tebeka
    Apr 7, 2013
Loading...

Share This Page