Transwiki:Packages in Java: Difference between revisions

From Wikibooks, open books for an open world
Jump to navigation Jump to search
Content deleted Content added
TRANSWIKI: Copied from Wikipedia:Packages in Java.
 
No edit summary
Line 1: Line 1:
{{Wikibookspar|Transwiki|Packages in Java}}
In the [[Java programming language]], a '''package''' is a group of related [[Class (computer science)|classes]] and [[Interface (computer science)|interfaces]]. Packages in Java have a close correspondence to packages in the [[Unified Modeling Language|UML]]; they are less closely related to [[Namespace (programming)|namespaces]] in [[C plus plus|C++]].
In the [[Java programming language]], a '''package''' is a group of related [[Class (computer science)|classes]] and [[Interface (computer science)|interfaces]]. Packages in Java have a close correspondence to packages in the [[Unified Modeling Language|UML]]; they are less closely related to [[Namespace (programming)|namespaces]] in [[C plus plus|C++]].



Revision as of 08:24, 28 November 2005

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 java.lang 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 java.lang, java.util, java.io, etc.) with the statement

import java.*;

and the statement

import java.lang.*;

will import all of the classes in the package java.lang, but not the packages java.lang.ref or java.lang.reflect. 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 org.xml.sax must be located in a directory org/xml/sax/. 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:

  • java.applet - Interface for applets
  • java.awt - Abstract Windowing Toolkit
  • java.awt.color - AWT color support
  • java.awt.datatransfer
  • java.awt.dnd - AWT drag and drop support
  • java.awt.event - AWT event model
  • java.awt.font - AWT font
  • java.awt.geom - AWT geometry specification
  • java.awt.im - AWT general input method support
  • java.awt.im.spi
  • java.awt.image - AWT image support
  • java.awt.image.renderable
  • java.awt.print - AWT printing support
  • java.beans - Java Beans specification for J2EE
  • java.beans.beancontext
  • java.io - Standard input/output API
  • java.lang
  • java.lang.annotation
  • java.lang.instrument
  • java.lang.management
  • java.lang.ref
  • java.lang.reflect
  • java.math - Big integer and big decimal classes
  • java.net - Basic internet API
  • java.nio - Non-blocking IO
  • java.nio.channels
  • java.nio.channels.spi
  • java.nio.charset
  • java.nio.charset.spi
  • java.rmi - Java remote method invocation API
  • java.rmi.activation
  • java.rmi.dgc
  • java.rmi.registry
  • java.rmi.server
  • java.security - Security
  • java.security.acl
  • java.security.cert
  • java.security.interfaces
  • java.security.spec
  • java.sql - SQL support
  • java.text - Advanced formatting for dates, numbers, etc.
  • java.util - Utility classes, including the Java collections framework
  • java.util.concurrent - Concurrency support
  • java.util.concurrent.atomic - Atomic operation support
  • java.util.concurrent.locks - Locks
  • java.util.jar - .jar file support
  • java.util.logging - Logging
  • java.util.prefs - System preference and configuration data
  • java.util.regex - Regular expression API
  • java.util.zip - .zip file support
  • javax.accessibility - Extensions for accessibility support
  • javax.activity - Activity service exceptions thrown by the ORB
  • javax.crypto - Cryptographic operations
  • javax.crypto.interfaces
  • javax.crypto.spec
  • javax.imageio - Image I/O
  • javax.imageio.event
  • javax.imageio.metadata
  • javax.imageio.plugins.bmp
  • javax.imageio.plugins.jpeg
  • javax.imageio.spi
  • javax.imageio.stream
  • javax.management - Extensions for VM management
  • javax.management.loading
  • javax.management.modelmbean
  • javax.management.monitor
  • javax.management.openmbean
  • javax.management.relation
  • javax.management.remote
  • javax.management.remote.rmi
  • javax.management.timer
  • javax.naming - Naming service support
  • javax.naming.directory
  • javax.naming.event
  • javax.naming.ldap
  • javax.naming.spi
  • javax.net - Extensions for Internet
  • javax.net.ssl
  • javax.print - Extensions for printing
  • javax.print.attribute
  • javax.print.attribute.standard
  • javax.print.event
  • javax.rmi - Extensions for RMI
  • javax.rmi.CORBA - RMI using CORBA
  • javax.rmi.ssl
  • javax.security.auth - Authentication and authorization
  • javax.security.auth.callback
  • javax.security.auth.kerberos - Kerberos support
  • javax.security.auth.login
  • javax.security.auth.spi
  • javax.security.auth.x500 - X.500 support
  • javax.security.cert
  • javax.security.sasl
  • javax.security.sasl
  • javax.servlet
  • javax.sound.midi - Java sound API for MIDI
  • javax.sound.midi.spi
  • javax.sound.sampled - Java sound API for sampled sound
  • javax.sound.sampled.spi
  • javax.sql - Extensions for SQL
  • javax.sql.rowset
  • javax.sql.rowset.serial
  • javax.sql.rowset.spi
  • javax.swing - Swing API
  • javax.swing.border
  • javax.swing.colorchooser
  • javax.swing.event
  • javax.swing.filechooser
  • javax.swing.plaf - Plugable look and feel support for Swing
  • javax.swing.plaf.basic
  • javax.swing.plaf.metal
  • javax.swing.plaf.multi
  • javax.swing.plaf.synth
  • javax.swing.table
  • javax.swing.text
  • javax.swing.text.html
  • javax.swing.text.html.parser
  • javax.swing.text.rtf
  • javax.swing.tree
  • javax.swing.undo - Undo support for Swing
  • javax.transaction
  • javax.transaction.xa
  • javax.xml - General XML API
  • javax.xml.datatype
  • javax.xml.namespace
  • javax.xml.parsers
  • javax.xml.transform
  • javax.xml.transform.dom
  • javax.xml.transform.sax
  • javax.xml.transform.stream
  • javax.xml.validation
  • javax.xml.xpath

Java Package Count

Package and class counts in Java
JDK version (year) Package count Class count
1.0 (1996) 8 212
1.1 (1997) 25 504
1.2 (1998) 59 1520
1.3 (2000) same same
1.4 (2002) 135 2991
5.0 (2004) 166 3562