开发者

package javax.servlet does not exist

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?


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.


It might be worth printing out the classpath from within the compile target, this would make it easier to determine if there are any classpath problems.

You can print classpaths inside ant targets using this technique.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜