Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Java Platform, Standard Edition

From Wikipedia, the free encyclopedia
Computing software platform
icon
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Java Platform, Standard Edition" – news ·newspapers ·books ·scholar ·JSTOR
(April 2018) (Learn how and when to remove this message)
Java Platform, Standard Edition
Player softwareJava
Programming language(s)Java
Application(s)Embedded systems,mobile devices
StatusActive
LicenseProprietary licence by Oracle
Websitewww.oracle.com/java/technologies/java-se-glance.html
Java platform editions

Java Platform, Standard Edition (Java SE) is acomputing platform,technical standard for development and deployment ofportable code fordesktop andserver environments.[1] Java SE was formerly known asJava 2 Platform, Standard Edition (J2SE).

The platform uses theJava programming language and is part of theJava software-platform family. Java SE defines a range of general-purposeAPIs—such asJava APIs for theJava Class Library—and also includes theJava Language Specification and theJava Virtual Machine Specification.[2]OpenJDK is the officialreference implementation since version 7.[3][4][5]

Nomenclature, standards and specifications

[edit]

The platform was known asJava 2 Platform, Standard Edition orJ2SE from version 1.2, until the name was changed toJava Platform, Standard Edition orJava SE in version 1.5. The "SE" is used to distinguish the base platform from the Enterprise Edition (Java EE) and Micro Edition (Java ME) platforms. 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 theJava version history. Starting with J2SE 1.4 (Merlin), Java SE has been developed under theJava Community Process, which produces descriptions of proposed and final specifications for the Java platform calledJava Specification Requests (JSR).[6] 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 (Java EE) is a related specification that includes all theclasses in Java SE, plus a number that are more useful to programs that run onservers as opposed toworkstations.

Java Platform, Micro Edition (Java ME) is a related specification intended to provide a certified collection of Java APIs for the development of software for small, resource-constrained devices such ascell phones,PDAs andset-top boxes.

TheJava Runtime Environment (JRE) andJava Development Kit (JDK) are the actual files downloaded and installed on a computer to run or develop Java programs, respectively.

General purpose packages

[edit]

The majority of these packages are exported by thejava.base module of theJava Platform Module System (since Java 9).

java.lang

[edit]

TheJava packagejava.lang contains fundamental classes andinterfaces closely tied to the language andruntime system. This includes the root classes that form theclass hierarchy, types tied to the language definition, basicexceptions, math functions,threading, security functions, as well as some information on the underlying native system. This package contains 22 of 32Error classes provided in JDK 6.

The main classes and interfaces injava.lang are:

Classes injava.lang are automatically imported into everysource file.

java.lang.ref

[edit]

Thejava.lang.ref package provides more flexible types ofreferences than are otherwise available, permitting limited interaction between the application and theJava Virtual Machine (JVM)garbage collector. It is an important package, central enough to the language for the language designers to give it a name that starts with "java.lang", but it is somewhat special-purpose and not used by a lot of developers. This package was added in J2SE 1.2.

Java has an expressive system of references and allows for special behavior for garbage collection. A normal reference in Java is known as a "strong reference". Thejava.lang.ref package defines three other types of references—soft,weak, and phantom references. Each type of reference is designed for a specific use.

  • ASoftReference can be used to implement acache. An object that is not reachable by a strong reference (that is, not strongly reachable), but is referenced by a soft reference is called "softly reachable". A softly reachable object may be garbage collected at the discretion of the garbage collector. This generally means that softly reachable objects are only garbage collected when free memory is low—but again, this is at the garbage collector's discretion. Semantically, a soft reference means, "Keep this object when nothing else references it, unless the memory is needed."
  • AWeakReference is used to implement weak maps. An object that is not strongly or softly reachable, but is referenced by a weak reference is called "weakly reachable". A weakly reachable object is garbage collected in the next collection cycle. This behavior is used in the classjava.util.WeakHashMap. A weak map allows the programmer to put key/value pairs in the map and not worry about the objects taking up memory when the key is no longer reachable anywhere else. Another possible application of weak references is thestring intern pool. Semantically, a weak reference means "get rid of this object when nothing else references it at the next garbage collection."
  • APhantomReference is used to reference objects that have been marked for garbage collection and have beenfinalized, but have not yet been reclaimed. An object that is not strongly, softly or weakly reachable, but is referenced by a phantom reference is called "phantom reachable." This allows for more flexible cleanup than is possible with the finalization mechanism alone. Semantically, a phantom reference means "this object is no longer needed and has been finalized in preparation for being collected."

Each of these reference types extends theReference class, which provides theget()method to return a strong reference to the referent object (ornull if the reference has been cleared or if the reference type is phantom), and theclear() method to clear the reference.

Thejava.lang.ref also defines the classReferenceQueue, which can be used in each of the applications discussed above to keep track of objects that have changed reference type. When aReference is created it is optionally registered with a reference queue. The application polls the reference queue to get references that have changed reachability state.

java.lang.reflect

[edit]

Reflection is a constituent of theJava API that lets Java code examine and "reflect" on Java components at runtime and use the reflected members. Classes in thejava.lang.reflect package, along withjava.lang.Class andjava.lang.Package accommodate applications such asdebuggers,interpreters, object inspectors,class browsers, and services such as objectserialization andJavaBeans that need access to either the public members of a target object (based on its runtime class) or the members declared by a given class. This package was added in JDK 1.1.

Reflection is used to instantiate classes and invoke methods using their names, a concept that allows for dynamic programming. Classes, interfaces, methods,fields, andconstructors can all be discovered and used at runtime. Reflection is supported bymetadata that the JVM has about the program.

Techniques
[edit]

There are basic techniques involved in reflection:

  • Discovery – this involves taking an object or class and discovering the members, superclasses, implemented interfaces, and then possibly using the discovered elements.
  • Use by name – involves starting with the symbolic name of an element and using the named element.
Discovery
[edit]

Discovery typically starts with an object and calling theObject.getClass() method to get the object'sClass. TheClass object has several methods for discovering the contents of the class, for example:

  • getMethods() – returns an array ofMethod objects representing all the public methods of the class or interface
  • getConstructors() – returns an array ofConstructor objects representing all the public constructors of the class
  • getFields() – returns an array ofField objects representing all the public fields of the class or interface
  • getClasses() – returns an array ofClass objects representing all the public classes and interfaces that are members (e.g.inner classes) of the class or interface
  • getSuperclass() – returns theClass object representing the superclass of the class or interface (null is returned for interfaces)
  • getInterfaces() – returns an array ofClass objects representing all the interfaces that are implemented by the class or interface
Use by name
[edit]

TheClass object can be obtained either through discovery, by using theclass literal (e.g.MyClass.class) or by using the name of the class (e.g.Class.forName("mypackage.MyClass")). With aClass object, memberMethod,Constructor, orField objects can be obtained using the symbolic name of the member. For example:

  • getMethod("methodName", Class...) – returns theMethod object representing the public method with the name "methodName" of the class or interface that accepts the parameters specified by theClass... parameters.
  • getConstructor(Class...) – returns theConstructor object representing the public constructor of the class that accepts the parameters specified by theClass... parameters.
  • getField("fieldName") – returns theField object representing the public field with the name "fieldName" of the class or interface.

Method,Constructor, andField objects can be used to dynamically access the represented member of the class. For example:

  • Field.get(Object) – returns anObject containing the value of the field from the instance of the object passed toget(). (If theField object represents a static field then theObject parameter is ignored and may benull.)
  • Method.invoke(Object, Object...) – returns anObject containing the result of invoking the method for the instance of the firstObject parameter passed toinvoke(). The remainingObject... parameters are passed to the method. (If theMethod object represents astatic method then the firstObject parameter is ignored and may benull.)
  • Constructor.newInstance(Object...) – returns the newObject instance from invoking the constructor. TheObject... parameters are passed to the constructor. (Note that the parameterless constructor for a class can also be invoked by callingnewInstance().)
Arrays and proxies
[edit]

Thejava.lang.reflect package also provides anArray class that contains static methods for creating and manipulating array objects, and since J2SE 1.3, aProxy class that supports dynamic creation of proxy classes that implement specified interfaces.

The implementation of aProxy class is provided by a supplied object that implements theInvocationHandler interface. TheInvocationHandler'sinvoke(Object, Method, Object[]) method is called for each method invoked on the proxy object—the first parameter is the proxy object, the second parameter is theMethod object representing the method from the interface implemented by the proxy, and the third parameter is the array of parameters passed to the interface method. Theinvoke() method returns anObject result that contains the result returned to the code that called the proxy interface method.

java.io

[edit]

Thejava.io package contains classes that supportinput and output. The classes in the package are primarilystream-oriented; however, a class forrandom accessfiles is also provided. The central classes in the package areInputStream andOutputStream, which areabstract base classes for reading from and writing tobyte streams, respectively. The related classesReader andWriter are abstract base classes for reading from and writing tocharacter streams, respectively. The package also has a few miscellaneous classes to support interactions with the hostfile system.

Streams

[edit]

The stream classes follow thedecorator pattern by extending the base subclass to add features to the stream classes. Subclasses of the base stream classes are typically named for one of the following attributes:

  • the source/destination of the stream data
  • the type of data written to/read from the stream
  • additional processing or filtering performed on the stream data

The stream subclasses are named using the namingpatternXxxStreamType whereXxx is the name describing the feature andStreamType is one ofInputStream,OutputStream,Reader, orWriter.

The following table shows the sources/destinations supported directly by thejava.io package:

Source/DestinationNameStream typesIn/outClasses
bytearray (byte[])ByteArraybytein, outByteArrayInputStream,ByteArrayOutputStream
char array (char[])CharArraycharin, outCharArrayReader,CharArrayWriter
fileFilebyte,charin, outFileInputStream,FileOutputStream,FileReader,FileWriter
string (StringBuffer)Stringcharin, outStringReader,StringWriter
thread (Thread)Pipedbyte,charin, outPipedInputStream,PipedOutputStream,PipedReader,PipedWriter

Other standard library packages provide stream implementations for other destinations, such as theInputStream returned by thejava.net.Socket.getInputStream() method or the Java EEjavax.servlet.ServletOutputStream class.

Data type handling and processing or filtering of stream data is accomplished through streamfilters. The filter classes all accept another compatible stream object as a parameter to the constructor anddecorate the enclosed stream with additional features. Filters are created by extending one of the base filter classesFilterInputStream,FilterOutputStream,FilterReader, orFilterWriter.

TheReader andWriter classes are really just byte streams with additional processing performed on the data stream to convert the bytes to characters. They use the defaultcharacter encoding for the platform, which as of J2SE 5.0 is represented by theCharset returned by thejava.nio.charset.Charset.defaultCharset() static method. TheInputStreamReader class converts anInputStream to aReader and theOutputStreamWriter class converts anOutputStream to aWriter. Both these classes have constructors that support specifying the character encoding to use. If no encoding is specified, the program uses the default encoding for the platform.

The following table shows the other processes and filters that thejava.io package directly supports. All these classes extend the correspondingFilter class.

OperationNameStream typesIn/outClasses
bufferingBufferedbyte,charin, outBufferedInputStream,BufferedOutputStream,BufferedReader,BufferedWriter
"push back" last value readPushbackbyte,charinPushbackInputStream,PushbackReader
read/writeprimitive typesDatabytein, outDataInputStream,DataOutputStream
object serialization (read/write objects)Objectbytein, outObjectInputStream,ObjectOutputStream

Random access

[edit]

TheRandomAccessFile class supportsrandom access reading and writing of files. The class uses afile 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 theseek(long) orskipBytes(int) methods. The current position of the file pointer is returned by thegetFilePointer() method.

File system

[edit]

TheFile class represents afile ordirectorypath in afile system.File objects support the creation, deletion and renaming of files and directories and the manipulation offile attributes such asread-only andlast modified timestamp.File objects that represent directories can be used to get a list of all the contained files and directories.

TheFileDescriptor class is afile descriptor that represents a source or sink (destination) of bytes. Typically this is a file, but can also be aconsole ornetwork socket.FileDescriptor objects are used to createFile streams. They are obtained fromFile streams andjava.net sockets and datagram sockets.

java.nio

[edit]
Main article:Non-blocking I/O (Java)

In J2SE 1.4, the packagejava.nio (NIO or Non-blocking I/O) was added to supportmemory-mapped I/O, facilitatingI/O operations closer to the underlying hardware with sometimes dramatically better performance. Thejava.nio package provides support for a number of buffer types. The subpackagejava.nio.charset provides support for differentcharacter encodings for character data. The subpackagejava.nio.channels provides support forchannels, which represent connections to entities that are capable of performing I/O operations, such as files and sockets. Thejava.nio.channels package also provides support for fine-grained locking of files.

java.math

[edit]

Thejava.math package supportsmultiprecision 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 throughRoundingMode.
  • BigInteger – provides arbitrary-precision integers. Operations onBigInteger do notoverflow or lose precision. In addition to standard arithmetic operations, it providesmodular arithmetic,GCD calculation,primality testing,prime number generation,bit manipulation, and other miscellaneous operations.
  • MathContext – encapsulate the context settings that describe certain rules for numerical operators.
  • RoundingMode – an enumeration that provides eight rounding behaviors.

java.net

[edit]

Thejava.net package provides special IO routines for networks, allowingHTTP requests, as well as other common transactions.

java.text

[edit]

Thejava.text package implements parsing routines for strings and supports various human-readable languages and locale-specific parsing.

java.util

[edit]

Data structures that aggregate objects are the focus of thejava.util package. Included in the package is theCollections API, an organized data structure hierarchy influenced heavily by thedesign patterns considerations.

Special purpose packages

[edit]

java.applet

[edit]
Main article:Java applet

Created to supportJava applet creation, thejava.applet package lets applications 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 adigital 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 the sandbox restrictions. Digital certificates are issued bycertificate authorities.

Because Java applets are now deprecated, this package is itself deprecated.

java.beans

[edit]
Main article:JavaBeans

Included in thejava.beans package are various classes for developing and manipulating beans, reusable components defined by theJavaBeans architecture. The architecture provides mechanisms for manipulating properties of components and firing events when those properties change.

The APIs injava.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 aGUI designer in anintegrated development environment.

java.awt

[edit]
Main article:Abstract Window Toolkit

Thejava.awt, or Abstract Window Toolkit, provides access to a basic set ofGUI 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 basiclayout managers, a datatransfer package for use with theClipboard andDrag and Drop, the interface toinput devices such asmice andkeyboards, as well as access to thesystem tray on supporting systems. This package, along withjavax.swing contains the largest number of enums (7 in all) in JDK 6.

java.rmi

[edit]
Main article:Java remote method invocation

Thejava.rmi package providesJava remote method invocation to supportremote procedure calls between two java applications running in differentJVMs.

java.security

[edit]

Support for security, including the message digest algorithm, is included in thejava.security package.

java.sql

[edit]
Main article:Java Database Connectivity

An implementation of theJDBC API (used to accessSQLdatabases) is grouped into thejava.sql package.

javax.rmi

[edit]
Main article:RMI-IIOP

Thejavax.rmi package provided support for the remote communication between applications, using the RMI over IIOP protocol. This protocol combines RMI and CORBA features.

Java SE Core Technologies - CORBA / RMI-IIOP

javax.swing

[edit]
Main article:Swing (Java)

Swing is a collection of routines that build onjava.awt to provide a platform independentwidget toolkit.javax.swing uses the 2D drawing routines to render the user interface components instead of relying on the underlying nativeoperating system GUI support.

This package contains the largest number of classes (133 in all) in JDK 6. This package, along withjava.awt also contains the largest number of enums (7 in all) in JDK 6. It supports 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 themodel–view–controller pattern, which loosens thecoupling 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.parser

[edit]

Thejavax.swing.text.html.parser package provides the error tolerant HTML parser that is used for writing various web browsers and web bots.

javax.xml.bind.annotation

[edit]

Thejavax.xml.bind.annotation package contained the largest number of Annotation Types (30 in all) in JDK 6. It defines annotations for customizing Java program elements to XML Schema mapping.

W3C packages

[edit]
Main article:Java API for XML Processing

Java contains packages forWorld Wide Web Consortium utilities (primarilyXML) under namespaceorg.w3c. Many of these exist in thejava.xml module.

DOM packages

[edit]

Theorg.w3c.dom packages provide interfaces for theDocument Object Model (DOM).

SAX packages

[edit]

Theorg.xml.sax packages provide interfaces for theSimple API for XML (SAX).

OMG packages

[edit]

org.omg.CORBA

[edit]
Main article:CORBA

Theorg.omg.CORBA package provided support for the remote communication between applications using theGeneral Inter-ORB Protocol and supports other features of thecommon object request broker architecture. Same asRMI andRMI-IIOP, this package is for calling remote methods of objects on other virtual machines (usually via network).

This package contained the largest number ofException classes (45 in all) in JDK 6. From all communication possibilities CORBA is portable between various languages; however, with this comes more complexity.

These packages were deprecated in Java 9 and removed from Java 11.[7]

org.omg.PortableInterceptor

[edit]

Theorg.omg.PortableInterceptor package contained the largest number of interfaces (39 in all) in JDK 6. It provides a mechanism to register ORB hooks through which ORB services intercept the normal flow of execution of the ORB.

Security

[edit]

Several critical security vulnerabilities have been reported.[8][9] Security alerts from Oracle announce critical security-related patches to Java SE.[10]

References

[edit]
  1. ^"Java SE Overview".Oracle Corporation. RetrievedFebruary 26, 2017.
  2. ^"Java SE 6 Release Contents".Oracle Corporation and/or its affiliates. RetrievedJanuary 1, 2013.
  3. ^Moving to OpenJDK as the official Java SE 7 Reference Implementation
  4. ^Java Platform, Standard Edition 7 Reference Implementations
  5. ^"Java Platform, Standard Edition 8 Reference Implementations". Archived fromthe original on November 21, 2015.
  6. ^"Java Specification Requests Overview".Oracle Corporation and/or its affiliates. RetrievedJanuary 1, 2013.
  7. ^"JEP 320: Remove the Java EE and CORBA Modules". Openjdk.java.net. 2019-05-23. Retrieved2022-03-20.
  8. ^Dangerous vulnerability in latest Java version The H Security, Jan. 10, 2013
  9. ^Darlene Storm (September 25, 2012)."Another critical Java vulnerability puts 1 billion users at risk".Computerworld Security Blog. Archived fromthe original on January 13, 2013. RetrievedJanuary 11, 2013.
  10. ^"Critical Patch Updates, Security Alerts and Third Party Bulletin". Oracle.

External links

[edit]
Platforms
Technologies
Oracle
Platform
Major
third-party
History
JVM
languages
Community
Conferences
Organizations
People
International
National
Retrieved from "https://en.wikipedia.org/w/index.php?title=Java_Platform,_Standard_Edition&oldid=1324428737"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp