File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes IDEs, Version Control and other tools and the fly likes adding external jars to a project in eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "adding external jars to a project in eclipse" Watch "adding external jars to a project in eclipse" New topic

adding external jars to a project in eclipse

sandeep raj

Joined: Mar 06, 2009
Posts: 10
I am currently using eclipse for my java project development. I wanted to know if there was a way to add external jars to all the java projects (including any new ones i might create in the future) directly in eclipse. I am aware of going through the project properties -> buildpath->add external jars for individual projects but is there a way i can do it for all the projects. I was hoping to find it under window -> preferences ->build path but was unable to find anything. Anyone knows if its possible?

edit: i guess i should have posted this question in the IDE section but i couldnt delete the topic so sorry about that ..
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46397
Don't think it is possible for every project in one stage. Remember it is likely that different projects will require different resources.

I shall move this thread to where we usually discuss IDEs.
Dawn Charangat
Ranch Hand

Joined: Apr 26, 2007
Posts: 249

Another way of doing this is to create a dummy project whih will hold all your jars, and you just add this dummy project in the classpath of your project.
But remember that eclipse [from 3.0] makes use of the OSGi container concepts.... hence until and unless you specify the jar, and its version usually
explicitly, it will not pick up the jar from its location. That is a standard feature of OSGi.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

I sometimes have a "lib" project that contains external jars. I don't have as many of them as I used to, however, since I use Maven a lot now.

There are some cases, however, where I find it better to go all the way back to the source. For example, I need the J2EE api jars from tomcat. For that, I define an external library. The Java/Build Path/User Libraries preferences allows me to create a TOMCAT user library and indicate the jars I want, giving their original locations in TOMCAT_HOME/lib. I can then reference that library in individual projects.

There are 2 benefits to that.

1. If I install a new version of Tomcat, I can change the user library and all projects will automatically pick up on it.

2. The ".classfile" will use the symbolic definition instead of absolute filesystem location. So it I check a project into CVS or Subversion and someone else checks it out, they can set up their own definition of the tomcat user library using whatever directory setup their particular machine happens to have.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: adding external jars to a project in eclipse
It's not a secret anymore!