This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
When do we typically need to add the path of the directory of .class files into CLASSPATH variable.
Is that useful for compiling the servlets files? I am not getting the exact use of it.
I read about this in a book named Core Servlets Volume-I 2nd Edition. Page 57 , Second chapter, Topic - Updating your CLASSPATH.
I am using Tomcat 5.5.28.
If you are working with servlets then you have to add servlet-api.jar (found in the tomcat's lib directory) to the CLASSPATH in order to compile your servlets. CLASSPATH is for pointing the compiler which places to look for classes/jar files etc.. which are not part of the core Java library but from the third parties. And you need that same additional classes/jar files when you run the program in order to let the JVM use them too.
However - it is important to remember that Tomcat does NOT use the CLASSPATH environment variable to run servlets. Tomcat has its own - rather complicated - rules which control where it looks for classes and library jar files. Your Tomcat installation should have a "class-loader-howto.html" file which explains this.