Set ClassPath in Servlet
How to Set ClassPath in Servlet
Installation of server
Download tomcat from the following url https://tomcat.apache.org/download-70.cgi Download tomcat select tomcate installer version(.exe), will get download as exe file, install into default location than "tomcate home directory" will be;
"C:\program files\apache software foundation\tomcat 6.0"
Or you can direct download from our website Tomcat 7.0 Download Tomcat 7.0
Hierarchy of Tomcat Server
Below I will give you description about all folder related to Tomcat Server and their uses.
- bin:\ This sub folder used to start and stop the tomcat server.
- conf:\ This folder is used to configure server port number for this use server.xml file.
- lib:\ This folder contains "servlet-api.jar" used to set classpath for servlet programming, this is vender specific.jar file for servlet programming.
- webapps:\ This is the web application deployment folder used to deploy web application by copying webroot or for copy you application.
classpath variable is set for providing path of all java classes which is used in our application. All classes related to servlet are available in lib/servlet-api.jar so we set classpath upto lib/servlet-api.jar.
Set Classpath in Servlet
Copy Servlet-api.jar file location and set the classpath in environment variable.
If your classpath is already set for core java programming, you need to edit classpath variable. for edit classpath just put ; at end of previous variable and paste new copied location (without delete previous classpath cariable).
In the above image you can see "C:\Program Files\Java\jdk1.6.0\jre\lib\rt.jar" path is already set now you can only put your servlet-api.jar location at the end of this path. Finally your complete path is;
C:\Program Files\Java\jdk1.6.0\jre\lib\rt.jar ; C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib\servlet-api.jar.;
Note: For read more about classpath you can read our core java concept Classpath