I am running ubuntu 14.04 and eclipse Kepler (with java ee modules preloaded) , I am developing Dynamic Web App for first time, it always says javax.servlet.xyz cannot be resolved to a type please help I am including a screen snapshot for my error page!
Asked
Active
Viewed 2.3k times
7
-
Have you added `servlet-api.jar` to your eclipse's build path? – Pradeep Simha Jun 27 '14 at 16:17
-
no I haven't please can you explain how to do it in ubuntu I don't even know where is Tomcat lib – Chinmaya B Jun 27 '14 at 16:18
-
@Creator check second answer http://stackoverflow.com/questions/860022/wheres-javax-servlet – Revive Jun 27 '14 at 16:20
-
You will get that in Server-> Runtime Configuration preferences window. – Pradeep Simha Jun 27 '14 at 16:22
-
@PradeepSimha- I don't get a runtime config option – Chinmaya B Jun 27 '14 at 16:24
-
@I-LOVE-2-REVIVE- I have installed the java EE already – Chinmaya B Jun 27 '14 at 16:27
-
@Creator read the second answer not the first. It will tell you how to add to your class path – Revive Jun 27 '14 at 16:28
-
I have read second answer and done everything according to it but I got following error msg Access restriction: The type ServletException is not accessible due to restriction on required library /usr/share/ java/servlet-api-3.0.jar – Chinmaya B Jun 27 '14 at 16:33
1 Answers
24
Only two things are required in Eclipse for this:
One
In Eclipse, Window -> Preferences -> Server -> Runtime Environment
Specify your Web Server or Application Server path, by adding a "New Server Runtime Environment".
Update
Initially, there are only few Server Runtime Environments available with Eclipse like:
- Apache
- Basic
- ObjectWeb
On an additional note, you can add more Server Adapters using the link Download additional server adapters
in Server Runtime Environments dialog screen.
Two
In Project Properties (Right Click on Project -> Properties), in Java Build Path, add Library "Server Runtime"
.
On adding Server Runtime to Project Library will add servlet-api.jar
and jsp-api.jar
jars to project dependencies.

Mandar Pandit
- 2,171
- 5
- 36
- 58
-
-
by the way if this was automated it would be easier...why is eclipse so much descriptive while using?? – Chinmaya B Jun 27 '14 at 16:41
-
I have given the answer considering Eclipse IDE, there might be different options available with other IDE's, which I am not aware much. So I mentioned that this answer is considering the Eclipse IDE. And one more point, the screenshot attached with the question is looks like to be a screenshot of Eclipse IDE. – Mandar Pandit Jun 27 '14 at 16:43