• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Error while compiling

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 3036
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
  •  
    Ranch Hand
    Posts: 46
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
     
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
     
    Marshal
    Posts: 73263
    332
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
     
    Sheriff
    Posts: 22257
    119
    Eclipse IDE Spring VI Editor Chrome Java Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Swing classes being the best known.
     
    Charbel Keyrouz
    Ranch Hand
    Posts: 46
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    These classes do not exist in the J2EE packages they only exist in the servlet-api.jar
     
    He's my best friend. Not yours. Mine. You can have this tiny ad:
    Thread Boost feature
    https://coderanch.com/t/674455/Thread-Boost-feature
    reply
      Bookmark Topic Watch Topic
    • New Topic