Transwiki:Packages in Java: Difference between revisions
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 appletsjava.awt
- Abstract Windowing Toolkitjava.awt.color
- AWT color supportjava.awt.datatransfer
java.awt.dnd
- AWT drag and drop supportjava.awt.event
- AWT event modeljava.awt.font
- AWT fontjava.awt.geom
- AWT geometry specificationjava.awt.im
- AWT general input method supportjava.awt.im.spi
java.awt.image
- AWT image supportjava.awt.image.renderable
java.awt.print
- AWT printing supportjava.beans
- Java Beans specification for J2EEjava.beans.beancontext
java.io
- Standard input/output APIjava.lang
java.lang.annotation
java.lang.instrument
java.lang.management
java.lang.ref
java.lang.reflect
java.math
- Big integer and big decimal classesjava.net
- Basic internet APIjava.nio
- Non-blocking IOjava.nio.channels
java.nio.channels.spi
java.nio.charset
java.nio.charset.spi
java.rmi
- Java remote method invocation APIjava.rmi.activation
java.rmi.dgc
java.rmi.registry
java.rmi.server
java.security
- Securityjava.security.acl
java.security.cert
java.security.interfaces
java.security.spec
java.sql
- SQL supportjava.text
- Advanced formatting for dates, numbers, etc.java.util
- Utility classes, including the Java collections frameworkjava.util.concurrent
- Concurrency supportjava.util.concurrent.atomic
- Atomic operation supportjava.util.concurrent.locks
- Locksjava.util.jar
- .jar file supportjava.util.logging
- Loggingjava.util.prefs
- System preference and configuration datajava.util.regex
- Regular expression APIjava.util.zip
- .zip file supportjavax.accessibility
- Extensions for accessibility supportjavax.activity
- Activity service exceptions thrown by the ORBjavax.crypto
- Cryptographic operationsjavax.crypto.interfaces
javax.crypto.spec
javax.imageio
- Image I/Ojavax.imageio.event
javax.imageio.metadata
javax.imageio.plugins.bmp
javax.imageio.plugins.jpeg
javax.imageio.spi
javax.imageio.stream
javax.management
- Extensions for VM managementjavax.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 supportjavax.naming.directory
javax.naming.event
javax.naming.ldap
javax.naming.spi
javax.net
- Extensions for Internetjavax.net.ssl
javax.print
- Extensions for printingjavax.print.attribute
javax.print.attribute.standard
javax.print.event
javax.rmi
- Extensions for RMIjavax.rmi.CORBA
- RMI using CORBAjavax.rmi.ssl
javax.security.auth
- Authentication and authorizationjavax.security.auth.callback
javax.security.auth.kerberos
- Kerberos supportjavax.security.auth.login
javax.security.auth.spi
javax.security.auth.x500
- X.500 supportjavax.security.cert
javax.security.sasl
javax.security.sasl
javax.servlet
javax.sound.midi
- Java sound API for MIDIjavax.sound.midi.spi
javax.sound.sampled
- Java sound API for sampled soundjavax.sound.sampled.spi
javax.sql
- Extensions for SQLjavax.sql.rowset
javax.sql.rowset.serial
javax.sql.rowset.spi
javax.swing
- Swing APIjavax.swing.border
javax.swing.colorchooser
javax.swing.event
javax.swing.filechooser
javax.swing.plaf
- Plugable look and feel support for Swingjavax.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 Swingjavax.transaction
javax.transaction.xa
javax.xml
- General XML APIjavax.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
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 |