File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Symbol not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Symbol not found" Watch "Symbol not found" New topic
Author

Symbol not found

john sayeau
Ranch Hand

Joined: Aug 23, 2010
Posts: 33
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

Joined: Aug 31, 2004
Posts: 11343

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.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
john sayeau
Ranch Hand

Joined: Aug 23, 2010
Posts: 33
Thanks! That did the trick.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Symbol not found
 
Similar Threads
javac compiling problem
Package Problem
Head First Servlets and JSp problem
Problem importing Dog class
Hi, package compiling question...