Cannot find symbol: javac no longer compiles my driver file when classes are placed in a package

noob here.

I have a group of class files which are used by a driver file. I originally wrote the files without any package statement and compiled the files using:

javac -d classes src/

Driver compiled without a hitch (though I had to add the path to the src directory in my .bash_profile CLASSPATH variable first)

Next, I added a package statement at the top of all my src files. The statement had the form:


Every src file got the same package statement. However the javac command now yields 62 “cannot find symbol” errors when executed. Every reference to another class file in my src directory fails.

I tried adding this import statement to each class file that extends or implements some parent class in the package:


Still, javac yields 62 “cannot find symbol” errors.

Do I need to modify my CLASSPATH variable to include the package? What am I doing wrong?


An alternative is create a directory to hold your Driver class. For instance:

mkdir -p src/edu/school/course/project
mv src/ src/edu/school/course/project

Then compile it:

javac -d classes src/edu/school/course/project/

You can put all your other related Java files in that same directory.

Assuming Driver has a main() method, to run it:

java -cp classes/

Leave a Reply

Your email address will not be published. Required fields are marked *