bit-question
bit-question

Reputation: 3843

Regarding Adding libraries in Eclipse

In eclipse, I am trying to add some libraries. I choose "build path->configure build path->libraries". The right column of the "java build path" window gives me several options: Add JARS, Add External JARS, and Add Library.

It seems to me that I should choose "Add Library", but what do the other two work for, "Add JARS" and "Add External JARS". What are the differences among these three options?

Upvotes: 2

Views: 2500

Answers (5)

Mark D
Mark D

Reputation: 5648

Add Jars is for internal Jars - i.e. jars from your project workspace. Add external Jars is for jars in a different directory on your hard drive - e.g. ones you downloaded or from a diff workspace. This is the same as "Add Library" really, except that a library is a handy label for external jars that you add regularly. See http://www.javaprogrammingforums.com/java-code-snippets-tutorials/6536-javatip-dec-18-2010-eclipse-user-libraries.html for an example of how to add.

Upvotes: 3

Vineet Reynolds
Vineet Reynolds

Reputation: 76709

'Add JARS' allows you to add JARs that are resident in the workspace to the project build path.

'Add External JARS', well, allows you to add JARs that are resident outside the workspace. You can add JARs that are inside the workspace, but the above option is meant to perform that.

Libraries, on the other hand, refer to the various predefined libraries in Eclipse. A library is usually an organized collection of JARs. It could refer to:

  • the JRE System library, consisting of JARs in the JDK/JRE used for building the project
  • a Java EE Server Runtime, made available through an installation of a WTP adapter for a server
  • User Libraries (that can be created by the user)
  • JDBC Connectivity Driver Definitions
  • Libraries that ship with Eclipse, like JUnit 3.x, 4.x.

Adding a Library adds all the entries specified in the library definition to the build path.

Upvotes: 1

FrVaBe
FrVaBe

Reputation: 49341

Have a look at this eclipse documentation - especially the Libraries tab section.

Upvotes: 0

Olaf
Olaf

Reputation: 6289

Add Library allows you to add a library defined in your Eclipse coniguration. If you check a project into a source control system and somebody checks it out, it would compile only if that developer has corresponding Eclipse libraries configured.

Add JARs allows to add jar files that are located in a subdirectory of your project's directory, usually named lib. You would check these jars into your source control system with your project and everyone who checks the project out would have these libraries.

Add External JARs is the least useful approach. It adds dependencies to the jar files of libraries located elsewhere on your computer and it hardcodes the pathnames of these files. If you check the project into a source control system and somebody checks it out, it would build only if they have the same libraries in the exact same places. Forget about teams using a mix of Windows, Mac and Linux workstations!

Upvotes: 1

Heathen
Heathen

Reputation: 633

  • Add Jars Lets you point to jars contained within your project.

  • Add External Jars Lets you point to jars anywhere on the file system.

  • Add Library Lets you point to a set of jars you have pre defined.

Upvotes: 0

Related Questions