I have one folder named library where I have put all my JAR files.
Now every time I create a new project, I have to copy all my JAR files in the lib folder to the WEB-INF folder.
Is there any way that I can add a folder permanently to all projects in Eclipse so that I don’t need to put all the JAR files again and again in new projects?
There are several ways of doing or approaching this.
Use a java endorsed library (if the jars correspond to an endorsable standard) (can be done outside eclipse). Be aware that this affects the Bootstrap Class loader (and so will the creation of an eclipse user system library).
Use a jars manually to your JRE library (inside eclipse). Window => Preferences = Java => Installed JRE, select one => add… => Add external jar. This will add the selected jar even to existing projects referring to this JRE. If you work with multiple JREs, you can have one “tweaked one” and a “standard one” for each Java version.
Define a user library (Window => Preferences => Java => Build Path => User libraries) This is commonly used to group jars. Still you will need to manually add the library to each project. Benefit: the jar are grouped (eg jdbc drivers, SWT version, etc…).
Define a library project (containing only jars and libraries) and manually add the library project to all projects in which you need these references.
Only the first 2 solutions are fully automated. Yet if you want to be able to opt out on a per-project basis, I’d recommend solution 3 (preferably) or 4. With solution 2, you can still opt out by using a standard JRE for untainted projects.
Now answering a question with another question. What is your use case when you need to add one or more jars to all projects ?