Andrew
Andrew

Reputation: 6404

Another way to compile java without servlet-api

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 compile it? Simply using the JDK?

Upvotes: 0

Views: 136

Answers (1)

Vivien Barousse
Vivien Barousse

Reputation: 20895

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.

Upvotes: 4

Related Questions