Java Class Library
The Java Class Library is a set of dynamically loadable libraries that Java Virtual Machine (JVM) languages can call at run time. It is the standard library of Java and other JVM languages, and is thus sometimes called the Java Standard Library. Because the Java Platform is not dependent on a specific operating system, applications cannot rely on any of the platform-native libraries. Instead, the Java Platform provides a comprehensive set of standard class libraries, containing the functions common to modern operating systems. Since Java 9, the Java Class Library can be accessed through module path using the Java Platform Module System.
JCL serves three purposes within the JVM:
- Like other standard code libraries, they provide the programmer a well-known set of useful facilities, such as container classes and regular expression processing.
- The library provides an abstract interface to tasks that would normally depend heavily on the hardware and operating system, such as network access and file access.
- Some underlying platforms may not support all of the features a Java application expects. In these cases, the library implementation can either emulate those features or provide a consistent way to check for the presence of a specific feature.
java.*, javax.*, and jdk.*. Some bundled classes may reside in namespaces like sun.* or com.sun.*, but they are not considered part of the standard library. The javax namespace was primarily associated with Java Platform, Enterprise Edition as extension packages to the Java standard library.Implementation and configuration
JCL is almost entirely written in Java, except for the parts that need direct access to the hardware and operating system, which are instead written in C++. The classes that give access to these functions commonly use Java Native Interface wrappers to access operating system APIs.Almost all of JCL is stored in a single Java archive file called "" which is provided with JRE and JDK distributions. The Java Class Library is located in the default bootstrap classpath and does not have to appear in the classpath declared for the application. The runtime uses the bootstrap class loader to find the JCL.
The Java Module System broke the monolithic "" JAR file and modularized the JCL itself in several modules with specified dependencies.
Conformance
Any Java implementation must pass the Java Technology Compatibility Kit tests for compliance, which includes JCL tests.Main features
JCL Features are accessed through classes provided in packages.- contains fundamental classes and interfaces closely tied to the language and runtime system.
- I/O and networking access the platform file system, and more generally networks through the, and packages. For networking, SCTP is available through.
- Mathematics package: provides mathematical expressions and evaluation, as well as arbitrary-precision decimal and integer number datatypes.
- Collections and Utilities : built-in Collection data structures, and utility classes, for regular expressions, concurrency, logging and data compression.
- GUI and 2D Graphics: the AWT package basic GUI operations and binds to the underlying native system. It also contains the 2D Graphics API. The Swing package is built on AWT and provides a platform-independent widget toolkit, as well as a pluggable look and feel. It also deals with editable and non-editable text components.
- Sound: interfaces and classes for reading, writing, sequencing, and synthesizing of sound data.
- Text: deals with text, dates, numbers and messages.
- Image package: and provide APIs to write, read, and modify images.
- XML: Simple [API for XML|SAX], DOM, StAX, XSLT transforms, XPath and various APIs for Web services, as SOAP protocol and JAX-WS.
- Security is provided by and encryption services are provided by.
- Databases: access to SQL databases via
- Access to Scripting engines: The package gives access to any conforming Scripting language.
- Applets: allows applications to be downloaded over a network and run within a guarded sandbox
- Java Beans: provides ways to manipulate reusable components.
- Introspection and reflection: represents a class, but other classes such as Method and Constructor are available in.
Packages outside of the main namespace
Java bundles some packages outside of the main namespaces. Among these include:netscape.javascript.*: classes for accessing the JavaScript engine and HTML DOM in the web browser. Deprecated in Java 24, for eventual moving to JavaFX.org.ietf.jgss.*: Generic Security Service API as specified by the Internet Engineering Task Force.org.omg.*: Object Management Group packages, such as Common Object Request Broker Architecture features. Deprecated since Java 9, removed since Java 11.org.w3c.dom.*: Document Object Model packages as specified by the World Wide Web Consortium.org.xml.sax.*: Simple API for XML packages related to XML.Implementation packages
Thesun.* and com.sun.* packages are all part of a module called jdk.unsupported. This module contains packages not part of the Java standard library but bundled as part of the Java implementation.Licensing
Prior licenses
Before the release of OpenJDK, the JDK was based on a proprietary license.Following their promise to release a fully buildable JDK based on almost completely free and open-source code in the first half of 2007, Sun released the complete source code of the Class Library under the GPL on May 8, 2007, except some limited parts that were licensed by Sun from third parties who did not want their code to be released under an open-source license. Sun's goal was to replace the parts that remain proprietary and closed source with alternative implementations and make the Class Library completely free and open source.
Until December 2010, the remaining encumbered part of the JDK was made available by Sun then Oracle as Binary Plugs which were required to build the JDK but not necessary to run it. as of 2007, the only part of the Class library that remained proprietary and closed-source was the SNMP implementation.
Since the first May 2007 release, Sun, with the help of the community, released as open-source or replaced with open-source alternatives almost all the encumbered code:
- All the audio engine code, including the software synthesizer, became open source. The closed-source software synthesizer has been replaced by a new synthesizer developed specifically for OpenJDK called Gervill.
- All cryptography classes were released as open-source.
- The code that scales and rasterizes fonts uses open source FreeType.
- The native color management uses open-source LittleCMS. There is a pluggable layer in the JDK, so that the commercial release of Java can use the original, proprietary color management system and OpenJDK can use LittleCMS.
- The anti-aliasing graphics rasterizer code uses the open source Pisces renderer used in the phoneME project.
- The JavaScript plugin is open source.
Open source release
Beginning in December 2010, all the so-called binary plugs were replaced by open source replacements, making the entire JDK open.Alternative implementations
GNU Classpath is the other main free software class library for Java. Contrary to other implementations, it only implements the Class Library, and is used by many free Java runtimes.Apache Harmony was another free software class library. Its aim was to implement the other parts of the Java stack.