Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

servlets error  RSS feed

 
Mudra desai
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!!
 
Campbell Ritchie
Marshal
Posts: 55717
163
  • 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: 55717
163
  • 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?
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37242
519
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!