How do I share an Eclipse User Library with other users?
Author: Deron Eriksson
Description: This tutorial describes how to export an Eclipse User Library to share with other users.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1) || Tomcat 6.0.14

An EclipseSW User Library can be used to group a set of jarW files, such as a set of TomcatSW jar files. In another tutorial, I created a user library called "TOMCAT_6.0.14_LIBRARY" for a set of Tomcat jar files.

In a group development setting, it can be useful to share a user library with other developers so that all developers can can gain the benefits of using a user library classpathW. It's beneficial for all developers to use the same user library so as to avoid jar file dependency issues.

You can share a user library with other developers by exporting your user library to an XMLW file. This XML file can then be imported by other developers.

To export a user library, to go Window → Preferences and go to JavaSW → Build Path → User Libraries. Here, click the Export button.

Export User Library

Select the user library or libraries to export. I selected the TOMCAT_6.0.14_LIBRARY library. Enter a destination location and name. I chose to export the file to my desktop and named the file "tomcat_6.0.14_library.xml". Click OK. Your user library should now be exported to a file.

Export User Library

The generated tomcat_6.0.14_library.xml file is shown below:


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<eclipse-userlibraries version="2">
    <library name="TOMCAT_6.0.14_LIBRARY" systemlibrary="false">
        <archive path="C:/dev/apache-tomcat-6.0.14/bin/bootstrap.jar"/>
        <archive path="C:/dev/apache-tomcat-6.0.14/bin/commons-daemon.jar"/>
        <archive path="C:/dev/apache-tomcat-6.0.14/bin/tomcat-juli.jar"/>
        <archive path="C:/dev/apache-tomcat-6.0.14/lib/annotations-api.jar"/>
        <archive path="C:/dev/apache-tomcat-6.0.14/lib/catalina.jar"/>
        <archive path="C:/dev/apache-tomcat-6.0.14/lib/catalina-ant.jar"/>
        <archive path="C:/dev/apache-tomcat-6.0.14/lib/catalina-ha.jar"/>
        <archive path="C:/dev/apache-tomcat-6.0.14/lib/catalina-tribes.jar"/>
        <archive path="C:/dev/apache-tomcat-6.0.14/lib/el-api.jar"/>
        <archive path="C:/dev/apache-tomcat-6.0.14/lib/jasper.jar"/>
        <archive path="C:/dev/apache-tomcat-6.0.14/lib/jasper-el.jar"/>
        <archive path="C:/dev/apache-tomcat-6.0.14/lib/jasper-jdt.jar"/>
        <archive path="C:/dev/apache-tomcat-6.0.14/lib/jsp-api.jar"/>
        <archive path="C:/dev/apache-tomcat-6.0.14/lib/servlet-api.jar"/>
        <archive path="C:/dev/apache-tomcat-6.0.14/lib/tomcat-coyote.jar"/>
        <archive path="C:/dev/apache-tomcat-6.0.14/lib/tomcat-dbcp.jar"/>

One important thing to notice is that the archive paths (the paths to the jar files) in the xmlW file are paths to the various jar files in the file system. If the other developers on your team are using the same location for Tomcat (C:/dev/apache-tomcat-6.0.14/), then they don't need to alter the file before importing the User Library. If their Tomcat installations are in a different location, then this file needs to be updated to contain the paths to their Tomcat installations before they import the file.

As a final note, the user library can be imported via the Import button at Java → Build Path → User Libraries.