0

I create new projects in Eclipse regularly and every time when I add a Servlet to one of them I get the error import javax.servlet can't be resolved

To solve this I have to add a jar to the project.

So is there any method such that the required JARs are added to all of my projects ,i.e., I don't have to add them again and again whenever I create a new project.

Angelo Fuchs
  • 9,825
  • 1
  • 35
  • 72
Vishal Chugh
  • 15
  • 1
  • 7
  • possible duplicate of [How to add external library properly in Eclipse?](http://stackoverflow.com/questions/2824515/how-to-add-external-library-properly-in-eclipse) – donfuxx Feb 26 '14 at 18:35
  • @donfuxx No the question u specified has an answer adding the libraries to a particular project only.But I'm asking to add a library for all the projects not just a single one. – Vishal Chugh Feb 26 '14 at 18:38

1 Answers1

1

You should be using Eclipse IDE for Java EE Developers and creating each project as a Dynamic Web Project. It will ask you which container you are using (like Apache Tomcat 7.0.x), but it will add the necessary JARs to the classpath for you. Anything you drop in your WEB-INF/lib folder will also be added automatically to the classpath.

davidfmatheson
  • 3,539
  • 19
  • 27
  • Though I've always added the JARs to WEB-INF/lib for each and every project I've created still it isn't automatically added to the classpath and isn't made available to the other projects.Thats why I'm all "hacked up". – Vishal Chugh Feb 26 '14 at 18:44
  • Do not add `servlet-api.jar` to `WEB-INF/lib` of your projects. Just create them as `Dynamic Web Project`s and tell it you're targeting `Apache Tomcat 7.0` (or whatever you use). – davidfmatheson Feb 26 '14 at 18:47