How to package Jar files to reuse in several projects, in Eclipse?

Posted on 2007-08-03
Last Modified: 2013-12-15
Eclipse question:
Hi,  I have a project called common in my Eclipse wbench. This project has some source files
and some jars from various locations - each one added manually from everywhere.

Now there are some other projects in the wbench and they need the same jar files. I do not want
to repeat adding the numerous jar files again and again for each project.

1)Is there a way to package all jar files to one Big jar file and use this jar file reference in other projects.
2)I will try referencing the common project by other projects but perhaps some project do need need to refer to
common project but just need the same jar files.
3)Any Ant script which could go fetch the jar files, so that I can use this script to import the jar files
in which ever project I may need?

Eclipse 3.2.1
Question by:Madhu_A
    LVL 9

    Accepted Solution

    If you are using eclipse, you can create a user library. You can add all the jars you want to this user library and then add this library to any project in your workspace. You can also create multiple such user libraries.

    To create go to window > preferences > java > build path > User Libraries

    Author Comment

    Hi, I went through the menu and was able to figure out how to create a User library and include it in which ever project I may want. Great!

    Sub questions:
    When I create a new user library it gives me an option to check which says - "added to the boot class - system library" - what does this mean?

    Also does the same logic apply to creating classpaths. Like create certain class paths and use them selectively to which ever project one may want.
    LVL 9

    Expert Comment

    Well AFAIK, there is no such thing as CREATING a classpath. Classpath specifies the location of classes and jars that you may need to run your program. When you are creating a library you are in essence adding those jar files and classes to the classpath itself.

    Author Comment

    In Eclipse there is :
    window > preferences > java > build path > class libraries
    as well along with the build path option where I added the user library. So I was wondering if a similar common set of class paths could be created for several projects to use.
    LVL 9

    Expert Comment

    Yes, I think you can definitely do that.

    Author Comment

    Ok, thanks.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Suggested Solutions

    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    Read about why website design really matters in today's demanding market.
    The viewer will learn how to implement Singleton Design Pattern in Java.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now