Spec-Zone .ru
спецификации, руководства, описания, API
Trail: Learning the Java Language
Lesson: Packages
Section: Creating and Using Packages
Summary of Creating and Using Packages
Home Page > Learning the Java Language > Packages

Summary of Creating and Using Packages

To create a package for a type, put a package statement as the first statement in the source file that contains the type (class, interface, enumeration, or annotation type).

To use a public type that's in a different package, you have three choices: (1) use the fully qualified name of the type, (2) import the type, or (3) import the entire package of which the type is a member.

The path names for a package's source and class files mirror the name of the package.

You might have to set your CLASSPATH so that the compiler and the JVM can find the .class files for your types.


Problems with the examples? Try Compiling and Running the Examples: FAQs.
Complaints? Compliments? Suggestions? Give us your feedback.

Previous page: Managing Source and Class Files
Next page: Questions and Exercises: Creating and Using Packages