How do I set my CLASSPATH for servlets?
Created May 4, 2012
That depends.
For developing servlets, just make sure that the JAR file containing javax.servlet.* is in your CLASSPATH, and use your normal development tools (javac and so forth).
- For JSDK: JSDK_HOME/lib/jsdk.jar
- For Tomcat: TOMCAT_HOME/lib/servlet.jar
The Servlets 2.2 spec says that the following should automatically be included by the container, so you shouldn't have to add them to your CLASSPATH manually. (Classloader implementations are notoriously buggy, though, so YMMV.)
- classes in the webapp/WEB-INF/classes directory
- JAR files in the webapp/WEB-INF/lib directory
The Complete CLASSPATH Guide for Servlets (http://www.meangene.com/java/classpath.html) by Gene McKenna (mckenna@meangene.com) has detailed instructions on how to set your CLASSPATH for JavaWebServer and JRun.
See also http://www.jguru.com/faq/view.jsp?EID=413601