This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Can not compile, please help me Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Can not compile, please help me" Watch "Can not compile, please help me" New topic
Author

Can not compile, please help me

Sandeep Mukherji
Ranch Hand

Joined: Mar 23, 2008
Posts: 46
Hi,
When I am trying to compile my code, following compile time error comes. I had set the classpath too.
Please help me.
***************************************************************************
D:\Servlet\Servlet1>set classpath=D:\Tomcat*\common\lib\servlet-api.jar

D:\Servlet\Servlet1>javac -d ./WEB-INF/classes LoginForm.java
LoginForm.java:1: package javax.servlet does not exist
import javax.servlet.*;
^
LoginForm.java:2: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
LoginForm.java:7: cannot find symbol
symbol: class HttpServlet
public class LoginForm extends HttpServlet{
^
LoginForm.java:8: cannot find symbol
symbol : class HttpServletRequset
location: class LoginForm
public void service(HttpServletRequset req, HttpServletResponse res)
^
LoginForm.java:8: cannot find symbol
symbol : class HttpServletResponse
location: class LoginForm
public void service(HttpServletRequset req, HttpServletResponse res)
^
LoginForm.java:9: cannot find symbol
symbol : class ServletException
location: class LoginForm
throws ServletException, IOException{
^
6 errors
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Sandeep Mukherji:
... I had set the classpath too.


It looks like it's not set correctly.
See:
http://faq.javaranch.com/java/CompilingServlets


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Sandeep Mukherji
Ranch Hand

Joined: Mar 23, 2008
Posts: 46
Hi ,

Thanks for the link. It's really very informative. But, please tell me which jar file(s) or class(es) is to be set in order to use the packages javax.servlet.* and javax.servlet.http.*
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The jar file is servlet-api.jar.

If you're using Tomcat 6.0 or higher it can be found in:
tomcat/lib

For 5x versions, it's in:
tomcat/common/lib
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Can not compile, please help me