Java Platform, Standard Edition or Java SE is a widely used platform for programming in the Java language. It is the Java Platform used to deploy portable applications for general use. In practical terms, Java SE consists of a virtual machine, which must be used to run Java programs, together with a set of libraries (or packages) needed to allow the use of file systems, networks, graphical interfaces, and so on, from within those programs.
Nomenclature, standards and specificationsJava SE was known as Java 2 Platform, Standard Edition or J2SE from version 1.2 until version 1.5. "SE" is used to distinguish the base platform from Java EE and Java ME. The "2" was originally intended to emphasize the major changes introduced in version 1.2, but was removed in version 1.6. The naming convention has been changed several times over the Java version history. Starting with J2SE 1.4 (Merlin), Java SE has been developed under the Java Community Process. JSR 59 was the umbrella specification for J2SE 1.4 and JSR 176 specified J2SE 5.0 (Tiger). Java SE 6 (Mustang) was released under JSR 270. Java Platform, Enterprise Edition is a related specification which includes all of the classes in Java SE, plus a number which are more useful to programs which run on servers as opposed to workstations. Java Platform, Micro Edition is a related specification intended to provide a certified collection of Java APIs for the development of software for small, resource-constrained devices such as cell phones, PDAs and set-top boxes. The JRE and JDK are the actual files that are downloaded and installed on a computer in order to run or develop java programs, respectively. General purpose packagesThe following are descriptions of some of the main Java SE packages. For a complete list of packages see the Java SE 6 API Javadocs.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Source/Destination | Name | Stream types | In/Out | Classes |
|---|---|---|---|---|
byte array (byte[]) |
ByteArray |
byte | in, out | ByteArrayInputStream, ByteArrayOutputStream |
char array (char[]) |
CharArray |
char |
in, out | CharArrayReader, CharArrayWriter |
| file | File |
byte, char |
in, out | FileInputStream, FileOutputStream, FileReader, FileWriter |
string (StringBuffer) |
String |
char |
in, out | StringReader, StringWriter |
thread (Thread) |
Piped |
byte, char |
in, out | PipedInputStream, PipedOutputStream, PipedReader, PipedWriter |
Other standard library packages provide stream implementations for other destinations, such as the InputStream returned by the java.net.Socket.getInputStream() method or the Java EE javax.servlet.ServletOutputStream class.
Data type handling and processing or filtering of stream data is accomplished through stream filters. The filter classes all accept another compatible stream object as a parameter to the constructor and decorate the enclosed stream with additional features. Filters are created by extending one of the base filter classes FilterInputStream, FilterOutputStream, FilterReader, or FilterWriter.
The Reader and Writer classes are really just byte streams with additional processing performed on the data stream to convert the bytes to characters. They use the default character encoding for the platform, which as of J2SE 5.0 is represented by the Charset returned by the java.nio.charset.Charset.defaultCharset() static method. The InputStreamReader class converts an InputStream to a Reader and the OutputStreamWriter class converts an OutputStream to a Writer. Both these classes have constructors that allow the character encoding to use to be specified—if no encoding is specified then the default encoding for the platform is used.
The following table shows the other processes and filters supported directly by the java.io package. All of these classes extend the corresponding Filter class.
| Operation | Name | Stream types | In/Out | Classes |
|---|---|---|---|---|
| buffering | Buffered |
byte, char |
in, out | BufferedInputStream, BufferedOutputStream, BufferedReader, BufferedWriter |
| "push back" last value read | Pushback |
byte, char |
in | PushbackInputStream, PushbackReader |
| read/write primitive types | Data |
byte |
in, out | DataInputStream, DataOutputStream |
| object serialization (read/write objects) | Object |
byte | in, out | ObjectInputStream, ObjectOutputStream |
The RandomAccessFile class supports random access reading and writing of files. The class uses a file pointer that represents a byte-offset within the file for the next read or write operation. The file pointer is moved implicitly by reading or writing and explicitly by calling the seek(long) or skipBytes(int) methods. The current position of the file pointer is returned by the getFilePointer() method.
The File class represents a file or directory path in a file system. File objects support the creation, deletion and renaming of files and directories and the manipulation of file attributes such as read-only and last modified timestamp. File objects that represent directories can be used to get a list of all of the contained files and directories.
The FileDescriptor class is a file descriptor that represents a source or sink (destination) of bytes. Typically this is a file, but can also be a console or network socket. FileDescriptor objects are used to create File streams. They are obtained from File streams and java.net sockets and datagram sockets.
java.nioIn J2SE 1.4, the package java.nio (NIO or New I/O) was added to support memory-mapped I/O, facilitating IO operations closer to the underlying hardware with sometimes dramatically better performance. The java.nio package provides support for a number of buffer types. The subpackage java.nio.charset provides support for different character encodings for character data. The subpackage java.nio.channels provides support for channels, which represent connections to entities that are capable of performing I/O operations, such as files and sockets. The java.nio.channels package also provides support for fine-grained locking of files.
java.mathThe java.math package supports multiprecision arithmetic (including modular arithmetic operations) and provides multiprecision prime number generators used for cryptographic key generation. The main classes of the package are:
BigDecimal – provides arbitrary-precision signed decimal numbers. BigDecimal gives the user control over rounding behavior through RoundingMode.BigInteger – provides arbitrary-precision integers. Operations on BigInteger do not overflow or lose precision. In addition to standard arithmetic operations, it provides modular arithmetic, GCD calculation, primality testing, prime number generation, bit manipulation, and other miscellaneous operations.MathContext – encapsulate the context settings which describe certain rules for numerical operators.RoundingMode – an enumeration that provides eight rounding behaviors.java.netThe java.net package provides special IO routines for networks, allowing HTTP requests, as well as other common transactions.
java.textThe java.text package implements parsing routines for strings and supports various human-readable languages and locale-specific parsing.
java.utilData structures that aggregate objects are the focus of the java.util package. Included in the package is the Collections API, an organized data structure hierarchy influenced heavily by the design patterns considerations.
java.appletCreated to support Java applet creation, the java.applet package allows applications to be downloaded over a network and run within a guarded sandbox. Security restrictions are easily imposed on the sandbox. A developer, for example, may apply a digital signature to an applet, thereby labeling it as safe. Doing so allows the user to grant the applet permission to perform restricted operations (such as accessing the local hard drive), and removes some or all of the sandbox restrictions. Digital certificates are issued by certificate authorities.
java.beansIncluded in the java.beans package are various classes for developing and manipulating beans, reusable components defined by the JavaBeans architecture. The architecture provides mechanisms for manipulating properties of components and firing events when those properties change.
Most of the APIs in java.beans are intended for use by a bean editing tool, in which beans can be combined, customized and manipulated. One type of bean editor is a GUI designer in an integrated development environment.
java.awtThe Abstract Window Toolkit provides access to a basic set of GUI widgets based on the underlying native platform's widget set, the core of the GUI event subsystem, and the interface between the native windowing system and the Java application. It also provides several basic layout managers, a datatransfer package for use with the Clipboard and Drag and Drop, the interface to input devices such as mice and keyboards, as well as access to the system tray on supporting systems. This package, along with javax.swing contains the maximum number of enums (7 in all) in JDK 6.
java.rmiThe java.rmi package provides Java remote method invocation to support remote procedure calls between two java applications running in different JVMs.
java.securitySupport for security, including the message digest algorithm, is included in the java.security package.
java.sqlAn implementation of the JDBC API (used to access SQL databases) is grouped into the java.sql package.
javax.rmiProvides the support for the remote communication between applications, using the RMI over IIOP protocol. This protocol combines RMI and CORBA features.
javax.swingSwing is a collection of routines that build on java.awt to provide a platform independent widget toolkit. Swing uses the 2D drawing routines to render the user interface components instead of relying on the underlying native operating system GUI support.
This package contains the maximum number of classes (133 in all) in JDK 6. This package, along with java.awt also contains the maximum number of enums (7 in all) in JDK 6. Thus it is a very rich system in its own right, supporting pluggable looks and feels (PLAFs) so that widgets in the GUI can imitate those from the underlying native system. Design patterns permeate the system, especially a modification of the model-view-controller pattern, which loosens the coupling between function and appearance. One inconsistency is that (as of J2SE 1.3) fonts are drawn by the underlying native system, and not by Java, limiting text portability. Workarounds, such as using bitmap fonts, do exist. In general, layouts are used and keep elements within an aesthetically consistent GUI across platforms.
javax.swing.text.html.parserProvides the error tolerant HTML parser that is used for writing various web browsers and web bots.
javax.xml.bind.annotationThis package contains the maximum number of Annotation Types (29 in all) in JDK 6. It defines annotations for customizing Java program elements to XML Schema mapping.
org.omg.CORBAProvides the support for the remote communication between applications using the General Inter-ORB Protocol and supports other features of the common object request broker architecture. Same as RMI and RMI-IIOP, this package is for calling remote methods of objects on other virtual machines (usually via network).
This package contains the maximum number of Exception classes (45 in all) in JDK 6. From all communication possibilities CORBA is the most portable between various languages; however, with this comes more complexity.
org.omg.PortableInterceptorThis package contains the maximum number of interfaces (39 in all) in JDK 6. It provides a mechanism to register ORB hooks through which ORB services can intercept the normal flow of execution of the ORB.