• 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

Symbol not found

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.





 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! That did the trick.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic