File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Adding CLASSPATH Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Adding CLASSPATH" Watch "Adding CLASSPATH" New topic
Author

Adding CLASSPATH

Sumukh Deshpande
Ranch Hand

Joined: Feb 17, 2008
Posts: 87

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.

Thanks in advance.

Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

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.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Sumukh Deshpande
Ranch Hand

Joined: Feb 17, 2008
Posts: 87

Thanks Vijitha Kumara. That answers my question.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12681
    
    5
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.

Bill

Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding CLASSPATH
 
Similar Threads
Problem in setting CLASSPATH
Running servlets
Where to place the Bean package in J2EE server
package package.name does not exist
Passing List from Servlet to jsp ? - value of list becomes NULL