I would like to add that the -classpath option overrides the existing classpath and uses only the jar mentioned in the command line. I had problems while compiling a servlet with 2 jar files. I added this one to the classpath in windows to overcome the problem.
Joined: Mar 21, 2005
In case antohy doesn't know... another way of doing it without adding to window's classpath could be:
1) you need to set your class path to the location where servlet-api.jar resides. here thst is, d:/tomcat/common/lib/servlet-api.jar
if you want to add some other location also, seoarate that with a semi colon, as I have done to add d:/tomcat/webapps/Test/WEB-INF/classes. I am considering that you are using other classes in your TestServlet.java, some Beans or whatever.
2) specify you destination location after -d option. I am considering that you want your class file to be in d:/tomcat/webapps/Test/WEB-INF/classes. So your TestServlet.class will be generated in this folder.
3)At last, specify the location of your source file. here that is d:/tomcat/webapps/Test/TestServlet.java.
4) If you have package statement in your servlet, say package com.example.web;
then you need to specify the parent directory of "com" as the destination folder, but you have to specify the full path to source file.