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

Can not compile, please help me

 
Sandeep Mukherji
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sandeep Mukherji
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic