Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Adding java package.

  1. #1
    Join Date
    Jan 2007
    Beans
    71

    Adding java package.

    Hi,

    In order to be able to work on a school project, i have to add several classes and jar s to the java class path. How do i do this?

    thx

  2. #2
    Join Date
    May 2005
    Location
    Paris, France
    Beans
    20
    Distro
    Xubuntu 10.04 Lucid Lynx

    Re: Adding java package.

    you can use the -cp or -classpath switch directly on your command line when launching your application:
    Code:
    java -cp somejar.jar exampleClass

  3. #3
    Join Date
    Jan 2007
    Beans
    71

    Re: Adding java package.

    But i want to add several classes and jars to the class path so this method is not sufficient.

  4. #4
    Join Date
    May 2005
    Location
    Paris, France
    Beans
    20
    Distro
    Xubuntu 10.04 Lucid Lynx

    Re: Adding java package.

    if you type java -? you'll get a list of all switches, and:
    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    A : separated list of directories, JAR archives,
    and ZIP archives to search for class files.
    that is, you can put a list of : separated items if you need to.

  5. #5
    Join Date
    Jan 2007
    Beans
    71

    Re: Adding java package.

    I don't want to use packages only when i run my program, i also want them to compile my classes in eclipse.

  6. #6
    Join Date
    May 2005
    Location
    Paris, France
    Beans
    20
    Distro
    Xubuntu 10.04 Lucid Lynx

    Re: Adding java package.

    In eclipse you have to define in
    - Project
    -- Properties
    in Java Build Path
    under the tab "Libraries":
    all the jars folders that you want in your class path

  7. #7
    Join Date
    Jan 2007
    Beans
    71

    Re: Adding java package.

    There seems to be a problem when i want to import a folder that contains only classes, not jars.

  8. #8
    Join Date
    Dec 2006
    Location
    Australia
    Beans
    1,097
    Distro
    Xubuntu 15.10 Wily Werewolf

    Re: Adding java package.

    Exactly what is the problem?

    I don't use Eclipse, but I think if anyone is to give a useful answer to your question, they'll need more specific descriptions.

  9. #9
    Join Date
    Jan 2006
    Location
    Leuven, Belgium
    Beans
    3,414

    Re: Adding java package.

    Right click your Project > properties > java build path > libraries tab. There you've got different options like "add external jar", "add library" and "add class folder", so that should be pretty intuitive.

  10. #10
    Join Date
    Jan 2007
    Beans
    71

    Re: Adding java package.

    Hi,

    what i actually want to do, is to add some jars and paths to the system variable classpath. (or that is what i should do in windows)

    for example, i need to add:
    folder a, b and c, d.jar, c.jar, e.jar
    to the system variable classpath. This way i can also run my application within the terminal.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •