John Doe John Doe - 1 month ago 5
Java Question

About compile servlets from command line: the provided solution didn't work

I'm trying to compile my servlet file from command line:
the command I type is:

javac -classpath E:\Programs\JavaEE\apache-tomcat\apache-tomcat-7.0.72-windows-x64\apache-tomcat-7.0.72\lib\servlet-api.jar DemoServlet.java


This is the method provided by most of the resources that I have seen online.
However, this doesn't work. The error happens as following:
enter image description here
So what's wrong with it? What did I miss?

Zia Zia
Answer

Please verify that servlet-api.jar exist in the folder and try to provide the complete package name of your Servlet(if your servlet class is in pacakge,eg com/john/DemoServlet) class.run the below command

javac -classpath .;E:\Programs\JavaEE\apache-tomcat\apache-tomcat-7.0.72-windows-x64\apache-tomcat-7.0.72\lib\servlet-api.jar com/john/DemoServlet.java
Comments