• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

servlets error  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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: 60806
190
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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: 60806
190
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
so where can I find answer to this?
 
author & internet detective
Marshal
Posts: 38666
677
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!