Meaningless Drivel is fun!
The moose likes Servlets and the fly likes Servlet Compilation Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Compilation Error" Watch "Servlet Compilation Error" New topic

Servlet Compilation Error

Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Hello All:
I am getting following compilation error while compiling servlet from folder
Package javax.servlet not found in import
Package javax.servlet.http not found in import
I have following setting on my NT machine
CLASSPATH = c:\jdk1.2.2;c:\jakarta-tomcat\lib;
JAVA_HOME = c:\jdk1.2.2;
TOMCAT_HOME = c:\jakarta-tomcat;
PATH = c:\jdk1.2.2;c:\jdk1.2.2\bin;c:\jakarta-tomcat\lib;
Am I missing some settings ?
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
The files in jakarta-tomcat\lib are "jar" files. Tomcat is smart enough to pick them all up when it is running, but if you want to compile your servlets using a regular Java compiler you need either (1) all these to be in your classpath individually, or (2) all of them to be in the jre\lib\ext directory of your SDK if you are using Java 2.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Prasad Charasala
Ranch Hand

Joined: Nov 02, 2000
Posts: 67
What Frank said is correct. In addition to that note down one more point, to keep .jar files in classpath you have to mention the full path of the jar file name. For example if you want to put c:\tomcat\lib\xxxx.jar in your classpath you have to put the entire thing like classpath=%classpath%;c:\tomcat\lib\xxxx.jar;c:\tomcat\lib\yyyy.jar . You just can not put like c:\tomcat\lib
May be because of this reason your compiler is not finding reqired classes.

Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Frank, Prasad
Thank you. I mentioned the full path of the jar file name in the CLASSPATH and it worked.
I agree. Here's the link:
subject: Servlet Compilation Error
It's not a secret anymore!