Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Symbol not found

 
john sayeau
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I'm trying to get a class to compile but it keeps getting Symbol not found:

Here is the directory tree of the project under /usr/tomcat/webapps/




here is the dog class :



Here is the class I'm tring to compile:



I try to compile it with this command:

javac -classpath WEB-INF/classes/com/example/:/usr/tomcat/lib/servlet-api.jar WEB-INF/classes/com/example/MyServletContextListener.java


and get this:

WEB-INF/classes/com/example/MyServletContextListener.java:10: cannot find symbol
symbol : class Dog
location: class com.example.MyServletContextListener
Dog d = new Dog("dogBreed");
^
WEB-INF/classes/com/example/MyServletContextListener.java:10: cannot find symbol
symbol : class Dog
location: class com.example.MyServletContextListener
Dog d = new Dog("dogBreed");


I've tried variations of the commad. I don't quite understand the arguments for -classpath I guess.





 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
john sayeau wrote: ...I try to compile it with this command:

javac -classpath WEB-INF/classes/com/example/:/usr/tomcat/lib/servlet-api.jar WEB-INF/classes/com/example/MyServletContextListener.java
...


Your Dog class is part of the package com.example, so its qualified name is "com.example.Dog," which is in the directory "classes." That's the directory you should specify in your classpath.

For reference, see Understanding the class path and package names.
 
john sayeau
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! That did the trick.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic