Transwiki:Packages in Java

In the Java programming language, a package is a group of related classes and interfaces. Packages in Java have a close correspondence to packages in the UML; they are less closely related to namespaces in C++.

Although it is conventional to name Java packages hierarchically, this hierarchy has no semantics in the language. For example, packages that begin with "java" are part of the Java language specification, and the package  and other packages that begin with "java.lang" contain classes that are core to the language. However, it is not possible to import all of the Java classes (for example, classes in,  ,  , etc.) with the statement import java.*; and the statement import java.lang.*; will import all of the classes in the package, but not the packages   or. This is in contrast to the hierarchical namespaces of C++.

Like class names, package names in Java specify the location of class files. Classes in the package  must be located in a directory. This rule has been criticized (primarily by the designers of C#) as unduly restrictive on the programmer. However, this restriction does simplify the design of the class loader.

Java packages that begin with "java" are part of the Java language specification. Packages that begin with "javax" are extensions to the specification, sometimes refining or replacing functionality in "java" packages. The java.*, javax.* and org.* packages make up the Java platform's official API - all implementions of J2SE that are "100% pure Java" should support these packages out of the box. Other packages are external to the platform.

Java packages other than those in the language specification follow a naming convention that ensures there are no naming conflicts. A package name should start with the domain name reversed, for example "com.sun" for packages from www.sun.com. Within a given company or educational institution, the rest of the package name follows a standard set by that company or institution, but a common organization is to have the next part of the package name indicate the department (so, for example "edu.mit.cs").

Packages in the language specification
As of version 5:


 * - Interface for applets
 * - Abstract Windowing Toolkit
 * - AWT color support
 * - AWT drag and drop support
 * - AWT event model
 * - AWT font
 * - AWT geometry specification
 * - AWT general input method support
 * - AWT image support
 * - AWT printing support
 * - Java Beans specification for J2EE
 * - Standard input/output API
 * - Big integer and big decimal classes
 * - Basic internet API
 * - Non-blocking IO
 * - Java remote method invocation API
 * - Security
 * - SQL support
 * - Advanced formatting for dates, numbers, etc.
 * - Utility classes, including the Java collections framework
 * - Concurrency support
 * - Atomic operation support
 * - Locks
 * - .jar file support
 * - Logging
 * - System preference and configuration data
 * - Regular expression API
 * - .zip file support
 * - Extensions for accessibility support
 * - Activity service exceptions thrown by the ORB
 * - Cryptographic operations
 * - Image I/O
 * - Extensions for VM management
 * - Naming service support
 * - Extensions for Internet
 * - Extensions for printing
 * - Extensions for RMI
 * - RMI using CORBA
 * - Authentication and authorization
 * - Kerberos support
 * - X.500 support
 * - Java sound API for MIDI
 * - Java sound API for sampled sound
 * - Extensions for SQL
 * - Swing API
 * - Plugable look and feel support for Swing
 * - Undo support for Swing
 * - General XML API
 * - Regular expression API
 * - .zip file support
 * - Extensions for accessibility support
 * - Activity service exceptions thrown by the ORB
 * - Cryptographic operations
 * - Image I/O
 * - Extensions for VM management
 * - Naming service support
 * - Extensions for Internet
 * - Extensions for printing
 * - Extensions for RMI
 * - RMI using CORBA
 * - Authentication and authorization
 * - Kerberos support
 * - X.500 support
 * - Java sound API for MIDI
 * - Java sound API for sampled sound
 * - Extensions for SQL
 * - Swing API
 * - Plugable look and feel support for Swing
 * - Undo support for Swing
 * - General XML API
 * - Naming service support
 * - Extensions for Internet
 * - Extensions for printing
 * - Extensions for RMI
 * - RMI using CORBA
 * - Authentication and authorization
 * - Kerberos support
 * - X.500 support
 * - Java sound API for MIDI
 * - Java sound API for sampled sound
 * - Extensions for SQL
 * - Swing API
 * - Plugable look and feel support for Swing
 * - Undo support for Swing
 * - General XML API
 * - Authentication and authorization
 * - Kerberos support
 * - X.500 support
 * - Java sound API for MIDI
 * - Java sound API for sampled sound
 * - Extensions for SQL
 * - Swing API
 * - Plugable look and feel support for Swing
 * - Undo support for Swing
 * - General XML API
 * - Java sound API for MIDI
 * - Java sound API for sampled sound
 * - Extensions for SQL
 * - Swing API
 * - Plugable look and feel support for Swing
 * - Undo support for Swing
 * - General XML API
 * - Swing API
 * - Plugable look and feel support for Swing
 * - Undo support for Swing
 * - General XML API
 * - Plugable look and feel support for Swing
 * - Undo support for Swing
 * - General XML API
 * - Undo support for Swing
 * - General XML API
 * - Undo support for Swing
 * - General XML API
 * - Undo support for Swing
 * - General XML API
 * - Undo support for Swing
 * - General XML API
 * - Undo support for Swing
 * - General XML API
 * - Undo support for Swing
 * - General XML API
 * - General XML API
 * - General XML API