Re: NoClassDefFoundError can't run class files
patrol wrote:
So correct me if I'm wrong, but you both seem to be saying that all
my .java source files should have a "package statement" consisting of
the directory in which the file resides? Then if you more your files,
No, inside the Java language a 'package' statement is just a namespace. The
correlation to directories is just how you organize packages on a hard drive.
you have to change all the package statements? That could be a lot of work!
Yes, it could, but in practice a) it doesn't happen all that often and b) you
usually use refactoring tools such as those in major Java IDEs to take the
sting out.
The files are just a convenience for representing the code and package
structures. What you really focus on is whether you refactor packages and
classes.
You only move files to different subdirectories when you refactor the packages
or classes, and not otherwise.
You only refactor packages or classes when the logic of your software design
motivates it.
If you do a reasonable package separation to begin with, it's never really
required to change every package and class in all your files. You might move
one, or a couple, or a few.
You think in terms of program structure; the file movement is a shadow of that
process.
The better Java IDEs have refactoring tools to ease the process.
--
Lew