Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error while compiling

 
thirun pavan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to learn J2EE using the head first servlet and JSP book, and while I was trying their first example there I wrote the following command:



then I got the following errors:



I am sure I have Java installed on my machine, so can someone please help me and tell me what exactly I am doing wrong here?

Thanks for your time
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, the Java compiler seems to be working. Otherwise you'd be getting a whole different kind of error. The only two possibilities I can think of are:

  • You don't have the servlet-api.jar in the location you have specified. Even a small typo would cause this problem.
  • The servelet-api.jar doesn't contain those packages and classes. As far as I know, it should, but it's easy to open up the jar and look for yourself.
  •  
    Charbel Keyrouz
    Ranch Hand
    Posts: 46
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    The servlet-api.jar does contain HttpServlet, HttpServletRequest and HttpServletResponse.
    The problem is in the path, make sure that you are pointing to the right path that contains the mentioned jar above.
     
    David Curry
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Just to be a bit more specific:

    HttpServlet, HttpServletRequest, and HttpServletResponse are all in the J2EE library. It may be that you only have Java SE (Java standard edition) installed. Be sure to download J2EE and place the j2ee.jar file in your classpath.

    Note: The "javax" in import javax.servlet.* is a sure sign that it is J2EE package.
     
    thirun pavan
    Greenhorn
    Posts: 22
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks all for your help and support...highly appreciated

    I found my mistake and it was in the path to the jar file, now everything is working fine

    Thanks again
     
    Campbell Ritchie
    Sheriff
    Pie
    Posts: 48968
    60
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    David Curry wrote:The "javax" in import javax.servlet.* is a sure sign that it is J2EE package.
    No, it isn't. There are J2SE classes in javax.* packages.
     
    Rob Spoor
    Sheriff
    Pie
    Posts: 20531
    54
    Chrome Eclipse IDE Java Windows
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Swing classes being the best known.
     
    Charbel Keyrouz
    Ranch Hand
    Posts: 46
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    These classes do not exist in the J2EE packages they only exist in the servlet-api.jar
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic