How to fix “javax.servlet cannot be resolved” error

How to set up class path in Eclipse IDE to include Server Runtime jars
(Aka I am getting errors that The import javax.servlet cannot be resolved. How do I fix it?)
If you get this compilation error, it means that you have not included the servlet jar in the classpath. The correct way to include this jar is to add the Server Runtime jar to your eclipse project. You should follow the steps below to address this issue:
Error Screen Shot:
Step 1- Right click on the project and open Configure Build Path menu (shown below):
Step 1 Screen Shot:
Step 2- Click on the libraries tab and choose Add library option:
Step 2 Screen Shot:
Step 3- From the Add Library screen, choose Server Runtime:
Step 3 Screen Shot:
Step 4- Choose Apache Tomcat v6.0 and hit finish:
Step 4 Screen Shot:
Now every thing is compiled correctly, as you would expect:
Step 5 Screen Shot:

About sansatechnology

Sansa Technology is an IT staffing, Consulting and Training company located in the heart of Silicon Valley. If you are a consultant looking for your new gig, send us your resume to us. If you are looking for training in the field of White Box Testing, Java, Java EE, Selenium, DevOps, Android and others, connect with us as well. Visit us at or email
This entry was posted in Computers and Internet. Bookmark the permalink.

12 Responses to How to fix “javax.servlet cannot be resolved” error

  1. Asım says:

    thanks you:) my problem solved 🙂

  2. hafiz muhammad danish says:

    thanks your method is working

  3. Pritish says:

    very greatful to you

  4. vandana says:


  5. Swathi says:

    thank u so much..:) 🙂 keep it up!!

  6. Pingback: How To Fix Javax Error in Windows

  7. Prajakta says:

    Thank you

  8. Sunitha says:

    very helpful..thanks 🙂

  9. Thanks Dude, your Answer is very helpful ….

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s