Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

package javax.servlet does not exist

Tags:

java

eclipse

When importing the javax.servlet package in the java file, this package is found by eclipse. However, when running an Ant build I get the error 'package javax.servlet does not exist'. I'm guessing this is a build path issue but I'm not sure how to fix it. I've refreshed and cleaned the project, changed the order of the build path and verified that the package is in the expected .jar file but the error will not go away. Any ideas?

like image 308
coder Avatar asked Feb 26 '23 22:02

coder


1 Answers

Inside eclipse, the compile is using the server runtime jars get these definitions.

In Ant you need to add the appropriate jar files.

For example, you can use the servlet-api.jar from Apache Tomcat's lib directory. This doesn't mean you can only deploy against tomcat, you should be able to deploy against any application server which implements the same version of the Servlet API.

like image 183
Dunderklumpen Avatar answered Mar 06 '23 17:03

Dunderklumpen