The Java Programming Language:
Packages and the Java Namespace
There have been a number of translations of this page, the authors of which have requested that links to their home pages as well as to the translation be included here. The situation (and the translations) were getting out of hand, and all have now been removed as I am not supposed to place what appear to be "sponsoring" links on my personal website here at the university. Thanks again to all those who supplied the translations.
Here are some things various authors have said about Java packages:
/rest_of_path/one/two/threewhile on a Windows system it might be
C:\rest_of_path\one\two\threeIn addition, the part of the path down to one/two/three (or one\two\three) must be part of the classpath for the given system.
SomeClass myObject = new SomeClass();
one.two.three.SomeClass myObject = new one.two.three.SomeClass();
javax. These packages themselves contain smaller packages (
java.io, for example). These classes are guaranteed to be available in all implementations.
java.lang, so you never have to explicitly import this package. It contains classes like
Math, and the "wrapper classes" for the primitive types, for example.
import java.io.*; import java.awt.*; import java.awt.event.*; import javax.swing.*
import java.awt.*;does not mean that you also get what is in the part of the library that you get by using this statement:
import java.awt.event.*;This should be clear if you just think for a moment about how package names relate to the directory structure used to store package files, but it is easy to make wrong assumptions about the package relationships when the package names are closely related.