开发者

Another way to compile java without servlet-api

开发者 https://www.devze.com 2023-04-11 15:12 出处:网络
Up to this point I used the Tomcat installation that comes with servlet-api.jar to compile my java files. Is there another way to开发者_如何学JAVA compile it? Simply using the JDK?Note: This answer su

Up to this point I used the Tomcat installation that comes with servlet-api.jar to compile my java files. Is there another way to开发者_如何学JAVA compile it? Simply using the JDK?


Note: This answer supposes your project includes some servlets, or other Servlet-related components, which can be guessed from your question.


No, you can't compile your project using only the JDK. The reason for this is that classes defined in servlet-api.jar does NOT exist in the standard class library, and the compiler does NOT know their definition (what are their methods, attributes, and so on).

If you want to use Servlet-related classes, you need to include a working copy of servlet-api.jar in your project. This copy can come from Tomcat, as in your case, or from another Servlet-compliant application server, such as GlassFish, JBoss, Jetty, or one of the many other existing ones.

0

精彩评论

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