CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2010
    Posts
    12

    java servlet not compiling

    i have set classpath=".;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet.jar".
    and compiled servlet program on the command line as-
    c:\>javac HowdyServlet.java
    then also it's not working
    any guesses!!

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: java servlet not compiling

    Post up the full text of the error message you get. Java error messages generally tell you what the problem is.

    Unless in communicating with it [a computer] one says exactly what one means, trouble is bound to result...
    A. Turing
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  3. #3
    Join Date
    Apr 2010
    Posts
    12

    Re: java servlet not compiling

    okay.

    C:\jwork>javac Howdyservlet.java
    Howdyservlet.java:3: package java.servlet.http does not exist
    import java.servlet.http.*;
    ^
    Howdyservlet.java:5: cannot find symbol
    symbol: class HttpServlet
    public class HowdyServlet extends HttpServlet{
    ^
    Howdyservlet.java:6: cannot find symbol
    symbol : class HttpServletRequest
    location: class HowdyServlet
    public void doGet(HttpServletRequest request,
    ^
    Howdyservlet.java:7: cannot find symbol
    symbol : class HttpServletResponse
    location: class HowdyServlet
    HttpServletResponse response)
    ^
    Last edited by aks01; May 3rd, 2010 at 06:26 AM.

  4. #4
    Join Date
    Feb 2008
    Posts
    966

    Re: java servlet not compiling

    Really need more information about how you are trying to run this. Are you trying to run this within the tomcat container? Did you create the folder structure under "webapps/" yourself and place the compiled class out there? Did you create the TOMCAT_HOME and CATALINA_HOME environment variables?

  5. #5
    Join Date
    Jun 2007
    Location
    Aurora CO USA
    Posts
    137

    Re: java servlet not compiling

    This error:
    Code:
    C:\jwork>javac Howdyservlet.java
    Howdyservlet.java:3: package java.servlet.http does not exist
    import java.servlet.http.*;
    ^
    Tells you what is wrong. HttpServlet is in package javax, not java. Change the import statement to
    Code:
    import javax.servlet.http.*;
    If you are still getting a package not found error, try this:

    Code:
    c:\>javac HowdyServlet.java -cp ".;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\servlet.jar".
    and see if you get the same error. If not, there is something wrong with the way you set your classpath. If so, the jars are still not being found.

    Let us know if you need more help.

  6. #6
    Join Date
    Apr 2010
    Posts
    12

    Smile Re: java servlet not compiling

    i have posted same question on multiple forums but none of them figured it out that servlet class is in javax package.
    hey senior brother thanks a lot.
    this problem have consumed my whole day, i have corrected the above said statement and is working like cheeseeee on the bread.
    thanks a lot for the time and the solution.
    once again thanks all of you for showing kindness and ofcourse for putting your brains in my problem.
    i will continue posting my problems here..
    thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured