Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Compilation Error

 
Dilip kumar
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All:
I am getting following compilation error while compiling servlet from folder
C:\jakarta-tomcat\webapps\examples\WEB-INF\classes\ValidateUser.java
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 ?
Thanks
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Prasad Charasala
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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.
------------------
Prasad
 
Dilip kumar
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frank, Prasad
Thank you. I mentioned the full path of the jar file name in the CLASSPATH and it worked.
Dilip
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic