Compiling files in a package
Suppose you have a package of java files in a folder called pack1.
To compile all the files within a package the following procedure is followed.
Move to the parent directory of the directory( or package) pack1.
This will compile all the .java files in the directory pack1 and generate class files for each class available in the package.
We can specify another directory for storing class files separately.
The following option is used with javac, in this case.
Set the destination directory for class files. The destination directory must already exist; javac will not create the destination directory. If a class is part of a package, javac puts the class file in a subdirectory reflecting the package name, creating directories as needed. For example, if you specify -d c:\myclasses and the class is called com.mypackage.MyClass, then the class file is called c:\myclasses\com\mypackage\MyClass.class.
If -d is not specified, javac puts the class file in the same directory as the source file.
Note that the directory specified by -d is not automatically added to your user class path.