This week's book giveaway is in the Kotlin forum. We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line! See this thread for details.
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
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
posted 1 year ago
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: 62846
203
posted 1 year ago
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.
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.