John Doe John Doe - 1 year ago 83
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

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 Source

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) 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/
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download