The Java Programming Language:
Packages and the Java Namespace
For a Russian translation of this page (thanks to Alisa Bagrii) see
and for a Latvian translation of the page (thanks to Nadia Karbowska) see
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.