• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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.
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic