Eclipse User Libraries – How to manage build path libraries for several projects easily

After switching my Workspace from Windows to Linux, I had to reconfigure the build-Path for each Eclipse project separately. This was a lot of work, so I took a look on how to manage build path libraries easily.

Eclipse ships a great solution for that, called „User Libraries“.

I will show you the advantages of user libraries and how to use them:

The Problem:

After switching my workspace to Linux, I had several Build Path errors like this:

 

The Solution:

To solve that, I had to reconfigure the build Path for all of my Projects in order to make them working.

This is a lot of work and if you want to upgrade your required Libraries (in this case you want to upgrade from ActiveMQ 5.4.3 to ActiveMQ 5.6.1) you have again to reconfigure all Build Paths that require that jar-File.

The Solution: User libraries

To avoid that, I decided to use User Libraries. How is it working? You can create your own libraries in which you can put several jar files (or classes). Then you have to reconfigure your build path in the projects to use the user libraries instead of the single jar files. If you now upgrade your Jar file (for Example ActiveMQ) you only have to modify your user library instead of all your project build paths.

 

Example in Pictures:

3 Projects that are using the same libraries:

Now we will create a User Library that contains the activemq-all.jar and log4j.jar file (Window -> Preferences:)

Add the needed jar-files to that library:

Then you see something like this:

Then you can reconfigure your projects to use this user library instead of the single jar-files (right click on project -> Build Path -> configure Build Path), remove the single jar files, and Add your user library (Add Library -> User Library -> „Your own Lib“):

Old build path:

New Path (with user library):

 

Projects View old:

 

Project View with user library:

 

Now you can apply that for all your Projects that are using ActiveMQ and/or log4j:

 

In the future you only have to maintain your user library and it will effect all the projects that are using that library:

Have fun with your own user libraries 😉