If you do not specify -d , the class file will be created in the same directory as the source file.
This is great if you already save your source in the directory structure corresponding to the structure of your package (and if you are happy that your source and class files live in the same place), but if your source structure does not match your package structure, basically you will get class files in places where they cannot be reasonably used.
Personally for anything other than a quick reset (usually Stack Overflow :) code I would make the following suggestions:
- Avoid using the default package
- Store the source code in a directory structure (e.g. with the root
src ) corresponding to the package structure - Generate class files in a separate directory structure (for example, with the root of
bin or out or classes )
(Sorry, I read the question incorrectly to start with.)
source share