Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

package javax.servlet.annotation does not exist

Tags:

java

servlets

I have some of the following imports defined like the following as shown in the image below.

enter image description here

I am wondering, how can I eliminate "package javax.servlet.annotation does not exist" error. I am currently working on "Java Web" type of project in Netbeans 7.4. .

Secondly, I believe , the above error is the reason behind my second error related to "WebServlet" which is shown in the image above (line #44).

Please let me know how to fix this problem.

Read some other posts like this one, but I believe they are not using Netbeans and not sure if I should update tomcat as mentioned in the post. The location of the servlet api jar file is as shown in the image below:

enter image description here

like image 680
rocky Avatar asked Jul 18 '14 19:07

rocky


2 Answers

Solution: Add Java EE Web API Library.

  1. In the project window, right-click <libraries>. Then click <Add Library>. then choose <Java EE Web API Library>
like image 86
ucheN Avatar answered Oct 24 '22 09:10

ucheN


WebServlet is added in servlet-api version 3.0, so make sure you are using updated version and it's added in the class path of the project.

Have a look at servlet-api-2.5 classes where WebServlet.class is not included, it's part of servlet-api-3.x classes

like image 21
Braj Avatar answered Oct 24 '22 07:10

Braj