What is a user library and how do I use it?
Author: Deron Eriksson
Description: This tutorial describes how to create a User Library in Eclipse.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 2.0 (Eclipse 3.3.0)


Page: < 1 2

(Continued from page 1)

Now, let's add the 'apache-tomcat-5.5.20-library' User Library to the project. I right-clicked the tomcat-demo project and went to Properties.

'tomcat-demo' properties

On the Libraries tab, I removed all of the old jarW files that had been added to the build path using the CATALINA_HOME ClasspathW Variable.

Removing jars from build path

I clicked Add Library.

Add Library to build path

I selected User Library and clicked Next.

Selecting User Library

I selected the 'apache-tomcat-5.5.20-library' User Library and clicked Finish.

Selecting 'apache-tomcat-5.5.20-library'

We can see that the 'apache-tomcat-5.5.20-library' has been added to the build path. On the Libraries tab, we can see that we've replaced all of the individual TomcatSW jar files with a single 'apache-tomcat-5.5.20-library' User Library.

Java Build Path Libraries

If we look at our .classpath file, we can see that all of the Tomcat jar files have been replaced by the single line:

	<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/apache-tomcat-5.5.20-library"/>
.classpath file

If you work on several projects with the same set of jar files, a User Library can be a great way of organizing and referencing those libraries. However, one thing to be aware of is that a User Library moves some of the build path information out of your project .classpath and moves it into EclipseSW, since a User Library's contents are stored by Eclipse in the Eclipse metadata, not in the individual project. So, if you have a complicated User Library that might be hard to replicate, it can be a good idea to export the User Library and store it in version control so that you have a record of the contents of the library. This can also let other developers replicate the environment required to run your application, since they can import the User Library into their Eclipse and use it.

Page: < 1 2