Jump to content

Java Platform, Standard Edition

From Alfawiki
Java Platform, Standard Edition
Company typeComputing platform
IndustrySoftware development
PredecessorJava 2 Platform, Standard Edition (J2SE)
Area served
Desktop and server systems
ProductsJava language, Java Class Library, Java Language Specification, Java Virtual Machine Specification
ParentJava software platform

Java Platform, Standard Edition (Java SE) represents a computing platform designed for creating and executing portable code across both desktop and server systems. Previously identified as Java 2 Platform, Standard Edition (J2SE), it utilizes the Java language and belongs to the extensive Java software platform suite. Java SE offers a collection of versatile APIs, including those found in the Java Class Library, alongside the Java Language Specification and the Java Virtual Machine Specification. From version 7 onward, OpenJDK has functioned as the official reference implementation.

Nomenclature, standards and specifications

From version 1.2 up to version 1.5, the platform was known as Java 2 Platform, Standard Edition (J2SE), after which it was renamed Java Platform, Standard Edition (Java SE). The abbreviation "SE" distinguishes it from Enterprise Edition (Java EE) and Micro Edition (Java ME). The numeral "2" initially emphasized significant updates in version 1.2 but was eliminated starting with version 1.6. Beginning with J2SE 1.4 (Merlin), development of Java SE adheres to the Java Community Process, which produces JSRs that define platform standards—such as JSR 59 for J2SE 1.4, JSR 176 for J2SE 5.0, and JSR 270 for Java SE 6.

The Java Platform, Enterprise Edition (Java EE) extends Java SE by incorporating APIs suited for server-side applications, whereas Java Platform, Micro Edition (Java ME) targets devices with limited resources like mobile phones and PDAs.

To operate or develop Java programs, users install either the JRE or the JDK, respectively.

General purpose packages

The majority of general-purpose packages are provided by the java.base module within the Java Platform Module System introduced in Java 9.

java.lang

The Java package java.lang comprises fundamental classes and interfaces essential to both the language and runtime environment. It contains foundational classes of the class hierarchy, language-specific types, critical exceptions for error handling, mathematical utilities, threading capabilities, security mechanisms, and system-related information. This package includes 22 out of 32 Error classes present in JDK 6.

Prominent classes and interfaces within java.lang include:

  • – serves as the root class for all class hierarchies.
  • – foundation for enumeration classes introduced in J2SE 5.0.
  • – central to Java's reflection capabilities.
  • – base class for all exceptions.
  • , , – key exception classes.
  • – supports thread management.
  • – handles strings and string literals.
  • and – classes dedicated to string manipulation (StringBuilder added since J2SE 5.0).
  • – interface facilitating generic object comparison (available since J2SE 1.2).
  • – interface enabling generic iteration compatible with enhanced for loops (introduced in J2SE 5.0).
  • System-related classes such as , , , , and oversee dynamic class loading, spawning external processes, querying environment properties, and enforcing security protocols.
  • Mathematical utility classes like and provide essential functions including trigonometric calculations and square roots (StrictMath introduced in J2SE 1.3).
  • Primitive wrapper classes encapsulate basic data types within objects.
  • Core exception classes address fundamental language errors and common exceptions.

All classes within java.lang are implicitly imported into every source file.

java.lang.ref

The package provides a variety of reference types that facilitate controlled interaction between Java applications and the Java Virtual Machine (JVM) garbage collector. Introduced with J2SE 1.2, this package is a specialized yet essential component of the Java platform.

In addition to the conventional "strong reference," it defines three distinct reference categories designed for particular use cases:

  • supports cache mechanisms by allowing objects referenced solely by soft references to be reclaimed when memory is scarce, thus balancing memory efficiency with cache retention.
  • forms the foundation of weak-keyed collections such as , which automatically remove entries when their keys become unreachable, enhancing memory management in extensive applications.
  • handles references to objects that have been finalized but not yet garbage collected, enabling sophisticated resource cleanup strategies beyond standard finalization.

Each of these extends the superclass, which offers methods such as to retrieve the referent and to clear the reference.

The package also includes , which monitors changes in reference states—this functionality is vital for managing object lifecycles and optimizing garbage collection in complex Java environments.

java.lang.reflect

Reflection represents a fundamental aspect of the Java API, empowering Java programs to examine and manipulate classes, methods, fields, and constructors dynamically at runtime. The package, together with java.lang.Class and , supports tools like debuggers, interpreters, object inspectors, class browsers, as well as services including object serialization and JavaBeans. Since its introduction in JDK 1.1, reflection enables dynamic behaviors such as creating instances and invoking methods by their names.

Techniques

Reflection encompasses two main approaches:

  • Discovery – uncovering members, superclasses, and interfaces associated with an object or class for utilization.
  • Name-based access – interacting with elements through their symbolic identifiers.
Discovery

Discovery starts by invoking the method on an object to obtain its corresponding Class object. This Class instance offers multiple methods to investigate class metadata, including:

  • – returns an array of objects representing all public methods.
  • – returns an array of objects for all public constructors.
  • – returns an array of objects corresponding to all public fields.
  • – returns an array of Class objects representing all public member classes and interfaces.
  • – returns the Class object for the superclass (returns null if it is an interface).
  • – returns an array of Class objects denoting implemented interfaces.
Use by name

A Class object can be obtained through discovery, using a class literal (e.g., MyClass.class), or by specifying the fully qualified class name (e.g., ). From this Class, specific member objects such as Method, Constructor, or Field can be retrieved by their symbolic names. For instance:

  • – fetches the Method corresponding to a public method named "methodName" with given parameter types.
  • – obtains the Constructor matching a public constructor with specified parameters.
  • – retrieves the Field representing a public field named "fieldName".

These retrieved objects allow dynamic interaction with class members:

  • – accesses the value of a field from an instance (not applicable for static fields).
  • – invokes a method on an instance with provided arguments (the first argument is ignored for static methods).
  • – creates a new instance by calling the constructor with supplied parameters; constructors without parameters can also be invoked via .
Arrays and proxies

Within the java.lang.reflect package, there is a class offering static methods designed for array creation and manipulation. Additionally, starting from J2SE 1.3, a class is provided to generate dynamic proxies that implement specified interfaces.

The functionality of a Proxy instance is determined by an object implementing the interface. Each method call on the proxy triggers the handler's method, which receives the proxy instance, the invoked Method, and the method's arguments, then returns an Object as the result back to the caller.

java.io

The package encompasses classes dedicated to I/O operations, with a focus on stream-based processing and support for random access file handling. Its fundamental classes include and , which serve as abstract foundations for reading from and writing to byte streams. Complementary classes such as and manage character streams. Further classes enable interaction with the underlying file system.

Streams

Stream-related classes employ the decorator pattern, enhancing base classes by layering additional capabilities. Naming conventions for subclasses follow the format XxxStreamType, where Xxx indicates the added feature and StreamType corresponds to one of InputStream, OutputStream, Reader, or Writer.

The supported sources and destinations include:

Source/Destination Designation Stream types Direction Classes
byte array (byte[]) ByteArray byte input, output Template:Javadoc:SE, Template:Javadoc:SE
char array (char[]) CharArray char input, output Template:Javadoc:SE, Template:Javadoc:SE
file File byte, char input, output Template:Javadoc:SE, Template:Javadoc:SE, Template:Javadoc:SE, Template:Javadoc:SE
string (StringBuffer) String char input, output Template:Javadoc:SE, Template:Javadoc:SE
thread (Thread) Piped byte, char input, output Template:Javadoc:SE, Template:Javadoc:SE, Template:Javadoc:SE, Template:Javadoc:SE

Other packages supply streams tailored for different endpoints, such as Java EE's or the providing an InputStream.

For managing data types and filtering streams, decorators extend base filter classes like to wrap existing streams.

The conversion between byte streams and character streams is handled by the Reader/Writer classes using the platform’s default encoding (since J2SE 5.0 via ). The classes and enable specifying character encodings explicitly; if not set, they default to the platform encoding.

Additional processing features offered by this package include:

Function Designation Stream types Direction Classes
buffering Buffered byte, char input, output Template:Javadoc:SE, Template:Javadoc:SE, Template:Javadoc:SE, Template:Javadoc:SE
"push back" last read value Pushback byte, char input only Template:Javadoc:SE, Template:Javadoc:SE
read/write primitive types Data byte input, output Template:Javadoc:SE, Template:Javadoc:SE
object serialization (read/write objects) Object byte input, output Template:Javadoc:SE, Template:Javadoc:SE


Random access

The class facilitates random access file operations by utilizing a file pointer that indicates the byte position for the next read or write action. This pointer automatically advances during input or output processes, but it can also be manually repositioned through the or methods. The current location of the pointer can be retrieved using .

File system

The class models a file or directory path within a file system. It allows for creating, deleting, renaming, and modifying attributes such as read-only status and last modified timestamps. When representing directories, it provides functionality to enumerate contained files and subdirectories.

The class serves as an abstraction for sources or destinations of byte streams, typically files but also including consoles or network sockets. Instances of FileDescriptor are employed to instantiate File streams and can be obtained from these streams as well as from java.net socket connections.

java.nio

Introduced with J2SE 1.4, the package supports memory-mapped I/O, enabling I/O processes to operate closer to hardware for enhanced performance. It provides multiple buffer implementations, while its subpackage manages various character encoding schemes. The subpackage offers channels that facilitate I/O connections to files and sockets and include advanced file locking mechanisms.

java.math

The package delivers capabilities for multiprecision arithmetic, including modular computations and prime number generation essential for cryptographic key creation. Important classes within this package include:

  • – represents arbitrary-precision signed decimal values with customizable rounding controlled by RoundingMode.
  • – handles arbitrary-precision integers without overflow or precision loss; supports modular arithmetic, greatest common divisor calculations, primality tests, prime number generation, bitwise operations, among others.
  • – encapsulates configuration settings governing numerical operations.
  • – defines eight distinct rounding modes as an enumeration.

java.net

The package provides specialized input/output utilities for networking, supporting tasks such as making HTTP requests and other typical network interactions.

java.text

This package offers parsing utilities tailored for string processing, accommodating multiple human languages and locale-specific formatting conventions.

java.util

Concentrating on Data structures that organize objects, the package includes the Collections API, a hierarchical data framework inspired by established design patterns.

java.applet

Created for developing Java applets, the package allows applications to be downloaded and executed within a controlled sandbox environment with enforced restrictions. Developers can apply digital signatures to applets to authorize restricted actions; these signatures are validated by trusted certificate authorities.

Note: Both Java applets and this package have been deprecated.

java.beans

The package offers classes designed for building and managing reusable components following the JavaBeans model. It supports manipulation of properties and event handling, primarily utilized in bean editing tools such as GUI designers embedded within integrated development environments.

java.awt

Known as the Abstract Window Toolkit, this package delivers fundamental GUI components that rely on native platform elements, manages GUI event handling, and interfaces directly with underlying windowing systems. It offers essential layout managers, supports data transfer mechanisms such as the Clipboard and Drag and Drop, provides input device handling for keyboards and mice, and grants access to the system tray on compatible operating systems. Together with javax.swing, it contains the highest number of enumerations in JDK 6.

java.rmi

This package enables Java remote method invocation, facilitating remote procedure calls between Java programs operating within separate JVM instances.

java.security

Security-related functionalities, including algorithms for message digest generation, are encompassed within this package.

java.sql

The package implements the JDBC API, providing interfaces to interact with SQL database systems.

javax.rmi

Supporting remote communication via the RMI over IIOP protocol, javax.rmi merges features from RMI and CORBA to enable interoperability between distributed applications.

javax.swing

Swing builds upon java.awt by supplying a platform-agnostic widget toolkit. Instead of depending on native OS GUI elements, it utilizes 2D graphics routines for rendering user interface components.

With 133 classes in JDK 6, it stands as the largest package by class count and contains seven enumerations. Swing facilitates pluggable look-and-feel (PLAF) support to emulate native system appearances. It employs design patterns akin to a modified model–view–controller architecture to decouple functionality from presentation. However, font rendering is delegated to the native system, which limits text portability across platforms. Layout managers are used to maintain consistent GUI layouts regardless of the environment.

javax.swing.text.html.parser

This package offers an HTML parser designed to be tolerant of errors, commonly utilized by web browsers and automated agents.

javax.xml.bind.annotation

Containing the greatest number of Annotation Types (30) in JDK 6, javax.xml.bind.annotation defines annotations that customize how Java objects map to XML Schema representations.

org.omg.CORBA

The org.omg.CORBA package supports remote method invocation using the General Inter-ORB Protocol, embodying core aspects of the CORBA specification. Similar to RMI and RMI-IIOP, it allows invoking methods on objects located in different virtual machines.

With 45 Exception classes—the highest count in JDK 6—CORBA ensures language interoperability at the cost of increased complexity. These packages were deprecated starting with Java 9 and subsequently removed in Java 11.

org.omg.PortableInterceptor

The org.omg.PortableInterceptor package contains the largest collection of interfaces (39) in JDK 6. It allows for registering ORB hooks that intercept and influence the execution flow within ORB services.

Security

Numerous significant security flaws have been identified over time, leading Oracle to release critical security updates for Java SE aimed at safeguarding its broad user community.

External links