Each Java™ class is part of a package. The first statement in a Java source file indicates which class is in what package. If the source file does not contain a package statement, the class is part of an unnamed default package.
The package name relates to the directory structure in which the class resides. The integrated file system supports Java classes in a hierarchical file structure that is similar to what you find on most PC and UNIX® systems. You must store a Java class in a directory with a relative directory path that matches the package name for that class. For example, consider the following Java class:
package classes.geometry; import java.awt.Dimension; public class Shape { Dimension metrics; // The implementation for the Shape class would be coded here ... }
The package statement in the previous code indicates that the Shape class is part of the classes.geometry package. For the Java runtime to find the Shape class, store the Shape class in the relative directory structure classes/geometry.
For example, when you store the Shape class in the /Product/classes/geometry directory in the "root" (/) file system, you need to specify /Product in the classpath.
Figure 1: Example directory structure for Java classes of the same name in different
packages
The Java compiler uses the Java classpath, package name, and directory structure to find packages and classes when compiling Java source code. For more information, see Java classpath.