• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Cannot find symbol  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Allright, here's the problem.

I'm starting to learn Java from scratch with the guidance of Heads first java book. I've come to a chapter, where I start to learn about objects and classes.

According to the excercise, I have to create 2 classes and use the method from one class in the another. Here are the source codes:

Dog.Java


DogTestDrive.java


The first class compiles just fine. However, when I try to compile the DogTestDrive.java file, I get this error in the compiler:



What could be the problem and how do I solve it?
Thank you in advance.
 
Ranch Hand
Posts: 2410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One question. In the Dog class, did you intend to have the /* in the code?
 
lowercase baba
Bartender
Posts: 12628
50
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is the file named "Dog.Java" or "Dog.java"?
 
Java Cowboy
Sheriff
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

The two classes are in the package Dog. You'll have to take that into account when you are compiling them. Specifically, these source files must be in a subdirectory named Dog, and then you must compile this from the base directory of the package.

C:\MyProject> javac Dog\Dog.java
C:\MyProject> javac Dog\DogTestDrive.java

C:\MyProject> java Dog.DogTestDrive
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!