• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

servlets error

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mudras-MacBook-Pro:listenerTest mudradesai$ javac -classpath Users/mudradesai/Downloads/apache-tomcat-8.5.15/lib/servlet-api.jar:classes:. -d classes src/com/example/web/MyServletContextListener.java
src/com/example/web/MyServletContextListener.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
src/com/example/web/MyServletContextListener.java:3: cannot find symbol
symbol: class ServletContextListener
public class MyServletContextListener implements ServletContextListener{
                                                ^
src/com/example/web/MyServletContextListener.java:4: cannot find symbol
symbol  : class ServletContextEvent
location: class com.example.MyServletContextListener
public void contextInitialized(ServletContextEvent event){
                              ^
src/com/example/web/MyServletContextListener.java:10: cannot find symbol
symbol  : class ServletContextEvent
location: class com.example.MyServletContextListener
public void contextDestroyed(ServletContextEvent event){
                            ^
src/com/example/web/MyServletContextListener.java:5: cannot find symbol
symbol  : class ServletContext
location: class com.example.MyServletContextListener
ServletContext sc = event.setServletContext();
^
src/com/example/web/MyServletContextListener.java:7: cannot find symbol
symbol  : class Dog
location: class com.example.MyServletContextListener
Dog d = new Dog(dogBreed);
^
src/com/example/web/MyServletContextListener.java:7: cannot find symbol
symbol  : class Dog
location: class com.example.MyServletContextListener
Dog d = new Dog(dogBreed);
           ^
7 errors


I cannot understand whts wrong.Kindly help!!
 
Marshal
Posts: 79153
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for showing us the classpath etc.

But where are those classes? In particular, where is the Dog class? Are you sure the context classes are in that .jar in the Apache directory? Are you sure they are in the classpath? You realise the javax.servlet package isn't part of JavaSE? You need JavaEE for it.
 
Mudra desai
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the dog class I have not yet coded.But I don't know how to solve this error what to do abt javaEE. I m using Macintosh.
 
Campbell Ritchie
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I may not know either. Start by unzipping or exploring those jar files and seeing whether they contain the classes you are looking for.

Don't use abbreviations like abt for reasons explained here.
 
Mudra desai
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so where can I find answer to this?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this really the path of the servlet jar on your machine? In particular, it looks like you are missing a leading slash.


Try running "ls Users/mudradesai/Downloads/apache-tomcat-8.5.15/lib/servlet-api.jar" from the directory you are running the javac command. If it doesn't work, there's the problem.
 
Mudra desai
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic