Java Platform, Standard Edition ( Java SE ) is a computing platform for development and deployment of portable code for desktop and server environments. Java SE was formerly known as Java 2 Platform, Standard Edition ( J2SE ).
91-754: The platform uses the Java programming language and is part of the Java software-platform family. Java SE defines a range of general-purpose APIs —such as Java APIs for the Java Class Library —and also includes the Java Language Specification and the Java Virtual Machine Specification . OpenJDK is the official reference implementation since version 7. The platform was known as Java 2 Platform, Standard Edition or J2SE from version 1.2, until
182-476: A Proxy class that supports dynamic creation of proxy classes that implement specified interfaces. The implementation of a Proxy class is provided by a supplied object that implements the InvocationHandler interface. The InvocationHandler 's invoke(Object, Method, Object[]) method is called for each method invoked on the proxy object—the first parameter is the proxy object,
273-495: A class rather than an instance. They are typically used as part of an object meta-model . I.e, for each class, defined an instance of the class object in the meta-model is created. Meta-model protocols allow classes to be created and deleted. In this sense, they provide the same functionality as constructors and destructors described above. But in some languages such as the Common Lisp Object System (CLOS)
364-465: 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 . The java.awt , or 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
455-410: 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
546-417: A few miscellaneous classes to support interactions with the host file system . The stream classes follow the decorator 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 stream subclasses are named using the naming pattern XxxStreamType where Xxx is the name describing
637-478: 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. In J2SE 1.4, the package java.nio (NIO or Non-blocking I/O) was added to support memory-mapped I/O , facilitating I/O operations closer to the underlying hardware with sometimes dramatically better performance. The java.nio package provides support for
728-717: A lawsuit against Google shortly after that for using Java inside the Android SDK (see the Android section). On April 2, 2010, James Gosling resigned from Oracle . In January 2016, Oracle announced that Java run-time environments based on JDK 9 will discontinue the browser plugin. Java software runs on everything from laptops to data centers , game consoles to scientific supercomputers . Oracle (and others) highly recommend uninstalling outdated and unsupported versions of Java, due to unresolved security issues in older versions. There were five primary goals in creating
819-437: A method defined on a shape class, triangle , etc. would each define the appropriate formula to calculate their area. The idea is to look at objects as "black boxes" so that changes to the internals of the object can be made with minimal impact on the other objects that use it. This is known as encapsulation and is meant to make code easier to maintain and re-use. Method overloading, on the other hand, refers to differentiating
910-636: 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. The 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
1001-482: A number of other standard servlet classes available, for example for WebSocket communication. The Java servlet API has to some extent been superseded (but still used under the hood) by two standard Java technologies for web services: Typical implementations of these APIs on Application Servers or Servlet Containers use a standard servlet for handling all interactions with the HTTP requests and responses that delegate to
SECTION 10
#17327717895651092-418: A number that are more useful to programs that run on servers as opposed to workstations . 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 as cell phones , PDAs and set-top boxes . The Java Runtime Environment (JRE) and Java Development Kit (JDK) are
1183-414: A process called Destruction . Destruction in most languages does not allow destructor method arguments nor return values. Destructors can be implemented so as to perform cleanup chores and other tasks at object destruction. In garbage-collected languages, such as Java , C# , and Python , destructors are known as finalizers . They have a similar purpose and function to destructors, but because of
1274-440: A small portion of code to which Sun did not hold the copyright. Sun's vice-president Rich Green said that Sun's ideal role with regard to Java was as an evangelist . Following Oracle Corporation 's acquisition of Sun Microsystems in 2009–10, Oracle has described itself as the steward of Java technology with a relentless commitment to fostering a community of participation and transparency. This did not prevent Oracle from filing
1365-614: A subject of controversy during the 2010s. The class library contains features such as: Javadoc is a comprehensive documentation system, created by Sun Microsystems . It provides developers with an organized system for documenting their code. Javadoc comments have an extra asterisk at the beginning, i.e. the delimiters are /** and */ , whereas the normal multi-line comments in Java are delimited by /* and */ , and single-line comments start with // . Method (computer science) A method in object-oriented programming (OOP)
1456-471: Is a procedure associated with an object , and generally also a message . An object consists of state data and behavior ; these compose an interface , which specifies how the object may be used. A method is a behavior of an object parametrized by a user. Data is represented as properties of the object, and behaviors are represented as methods. For example, a Window object could have methods such as open and close , while its state (whether it
1547-561: Is a collection of routines that build on java.awt to provide a platform independent widget toolkit . javax.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 largest number of classes (133 in all) in JDK 6. This package, along with java.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
1638-485: Is a constituent of the Java API that lets Java code examine and "reflect" on Java components at runtime and use the reflected members. Classes in the java.lang.reflect package, along with java.lang.Class and java.lang.Package accommodate applications such as debuggers , interpreters , object inspectors, class browsers , and services such as object serialization and JavaBeans that need access to either
1729-481: Is a method that is called at the beginning of an object's lifetime to create and initialize the object, a process called construction (or instantiation ). Initialization may include an acquisition of resources. Constructors may have parameters but usually do not return values in most languages. See the following example in Java: A Destructor is a method that is called automatically at the end of an object's lifetime,
1820-468: 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
1911-576: Is actually two compilers in one; and with GraalVM (included in e.g. Java 11, but removed as of Java 16) allowing tiered compilation . Java itself is platform-independent and is adapted to the particular platform it is to run on by a Java virtual machine (JVM), which translates the Java bytecode into the platform's machine language. Programs written in Java have a reputation for being slower and requiring more memory than those written in C++ . However, Java programs' execution speed improved significantly with
SECTION 20
#17327717895652002-411: Is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let programmers write once, run anywhere ( WORA ), meaning that compiled Java code can run on all platforms that support Java without the need to recompile. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of
2093-409: Is implicitly allocated on the stack or explicitly allocated and deallocated from the heap . In the latter case, the responsibility of managing memory resides with the programmer. If the program does not deallocate an object, a memory leak occurs. If the program attempts to access or deallocate memory that has already been deallocated, the result is undefined and difficult to predict, and the program
2184-626: Is insufficient free memory on the heap to allocate a new object; this can cause a program to stall momentarily. Explicit memory management is not possible in Java. Java does not support C/C++ style pointer arithmetic , where object addresses can be arithmetically manipulated (e.g. by adding or subtracting an offset). This allows the garbage collector to relocate referenced objects and ensures type safety and security. As in C++ and some other object-oriented languages, variables of Java's primitive data types are either stored directly in fields (for objects) or on
2275-461: Is known as a "strong reference". The java.lang.ref package defines three other types of references—soft, weak , and phantom references. Each type of reference is designed for a specific use. Each of these reference types extends the Reference class, which provides the get() method to return a strong reference to the referent object (or null if the reference has been cleared or if
2366-399: Is likely to become unstable or crash. This can be partially remedied by the use of smart pointers , but these add overhead and complexity. Garbage collection does not prevent logical memory leaks, i.e. those where the memory is still referenced but never used. Garbage collection may happen at any time. Ideally, it will occur when a program is idle. It is guaranteed to be triggered if there
2457-420: Is no longer needed, typically when objects that are no longer needed are stored in containers that are still in use. If methods for a non-existent object are called, a null pointer exception is thrown. One of the ideas behind Java's automatic memory management model is that programmers can be spared the burden of having to perform manual memory management. In some languages, memory for the creation of objects
2548-423: Is open or closed at any given point in time) would be a property. In class-based programming , methods are defined within a class , and objects are instances of a given class. One of the most important capabilities that a method provides is method overriding - the same name (e.g., area ) can be used for multiple different kinds of classes. This allows the sending objects to invoke behaviors and to delegate
2639-538: Is supported for interfaces . Java uses comments similar to those of C++. There are three different styles of comments: a single line style marked with two slashes ( // ), a multiple line style opened with /* and closed with */ , and the Javadoc commenting style opened with /** and closed with */ . The Javadoc style of commenting allows the user to run the Javadoc executable to create documentation for
2730-517: Is the Collections API , an organized data structure hierarchy influenced heavily by the design patterns considerations. Created to support Java applet creation, the java.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 a digital signature to an applet, thereby labeling it as safe. Doing so allows
2821-451: Is the latest version (Java 22, and 20 are no longer maintained). Java 8, 11, 17, and 21 are previous LTS versions still officially supported. James Gosling , Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991. Java was originally designed for interactive television, but it was too advanced for the digital cable television industry at the time. The language
Java Platform, Standard Edition - Misplaced Pages Continue
2912-431: Is written inside classes, and every data item is an object, with the exception of the primitive data types, (i.e. integers, floating-point numbers, boolean values , and characters), which are not objects for performance reasons. Java reuses some popular aspects of C++ (such as the printf method). Unlike C++, Java does not support operator overloading or multiple inheritance for classes, though multiple inheritance
3003-593: The ConcurrentMaps and other multi-core collections, and it was improved further with Java 1.6. Some platforms offer direct hardware support for Java; there are micro controllers that can run Java bytecode in hardware instead of a software Java virtual machine, and some ARM -based processors could have hardware support for executing Java bytecode through their Jazelle option, though support has mostly been dropped in current implementations of ARM. Java uses an automatic garbage collector to manage memory in
3094-552: The Java Community Process , which produces descriptions of proposed and final specifications for the Java platform called Java Specification Requests (JSR) . 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 the classes in Java SE, plus
3185-548: The Java 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
3276-418: The object lifecycle . The programmer determines when objects are created, and the Java runtime is responsible for recovering the memory once objects are no longer in use. Once no references to an object remain, the unreachable memory becomes eligible to be freed automatically by the garbage collector. Something similar to a memory leak may still occur if a programmer's code holds a reference to an object that
3367-516: The stack (for methods) rather than on the heap, as is commonly true for non-primitive data types (but see escape analysis ). This was a conscious decision by Java's designers for performance reasons. Java contains multiple types of garbage collectors. Since Java 9, HotSpot uses the Garbage First Garbage Collector (G1GC) as the default. However, there are also several other garbage collectors that can be used to manage
3458-576: 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. The javax.swing.text.html.parser package provides
3549-532: The JVM has about the program. There are basic techniques involved in reflection: Discovery typically starts with an object and calling the Object.getClass() method to get the object's Class . The Class object has several methods for discovering the contents of the class, for example: The Class object can be obtained either through discovery, by using the class literal (e.g. MyClass.class ) or by using
3640-625: 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 largest number of enums (7 in all) in JDK 6. The java.rmi package provides Java remote method invocation to support remote procedure calls between two java applications running in different JVMs . Support for security, including
3731-834: The Java language, as part of J2SE 5.0. Prior to the introduction of generics, each variable declaration had to be of a specific type. For container classes, for example, this is a problem because there is no easy way to create a container that accepts only specific types of objects. Either the container operates on all subtypes of a class or interface, usually Object , or a different container class has to be created for each contained class. Generics allow compile-time type checking without having to create many container classes, each containing almost identical code. In addition to enabling more efficient code, certain runtime exceptions are prevented from occurring, by issuing compile-time errors. If Java prevented all runtime type errors ( ClassCastException s) from occurring, it would be type safe . In 2016,
Java Platform, Standard Edition - Misplaced Pages Continue
3822-950: The Java language: As of November 2024 , Java 8, 11, 17, and 21 are supported as long-term support (LTS) versions, with Java 25, releasing in September 2025, as the next scheduled LTS version. Oracle released the last zero-cost public update for the legacy version Java 8 LTS in January 2019 for commercial use, although it will otherwise still support Java 8 with public updates for personal use indefinitely. Other vendors such as Adoptium continue to offer free builds of OpenJDK's long-term support (LTS) versions. These builds may include additional security patches and bug fixes. Major release versions of Java, along with their release dates: Sun has defined and supports four editions of Java targeting different application environments and segmented many of its APIs so that they belong to one of
3913-440: The Java platform must run similarly on any combination of hardware and operating system with adequate run time support. This is achieved by compiling the Java language code to an intermediate representation called Java bytecode , instead of directly to architecture-specific machine code . Java bytecode instructions are analogous to machine code, but they are intended to be executed by a virtual machine (VM) written specifically for
4004-635: The ability to run Java applets within web pages, and Java quickly became popular. The Java 1.0 compiler was re-written in Java by Arthur van Hoff to comply strictly with the Java 1.0 language specification. With the advent of Java 2 (released initially as J2SE 1.2 in December 1998 – 1999), new versions had multiple configurations built for different types of platforms. J2EE included technologies and APIs for enterprise applications typically run in server environments, while J2ME featured APIs optimized for mobile applications. The desktop version
4095-439: The actual files downloaded and installed on a computer to run or develop Java programs, respectively. The Java package java.lang contains fundamental classes and interfaces closely tied to the language and runtime system. This includes the root classes that form the class hierarchy , types tied to the language definition, basic exceptions , math functions, threading , security functions, as well as some information on
4186-594: The average price of all products. A static method can be invoked even if no instances of the class exist yet. Static methods are called "static" because they are resolved at compile time based on the class they are called on and not dynamically as in the case with instance methods, which are resolved polymorphically based on the runtime type of the object. In Java, a commonly used static method is: This static method has no owning object and does not run on an instance. It receives all information from its arguments. Copy-assignment operators define actions to be performed by
4277-404: The benefits of object-oriented development. Perhaps the most well-known example is C++ , an object-oriented extension of the C programming language. Due to the design requirements to add the object-oriented paradigm on to an existing procedural language, message passing in C++ has some unique capabilities and terminologies. For example, in C++ a method is known as a member function . C++ also has
4368-428: 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 the java.io package directly supports. All these classes extend the corresponding Filter class. The RandomAccessFile class supports random access reading and writing of files. The class uses a file pointer that represents
4459-419: The code used to handle a message based on the parameters of the method. If one views the receiving object as the first parameter in any method then overriding is just a special case of overloading where the selection is based only on the first argument. The following simple Java example illustrates the difference: Accessor methods are used to read the data values of an object. Mutator methods are used to modify
4550-421: The compiler generates code to call them at appropriate times. Static methods are meant to be relevant to all the instances of a class rather than to any specific instance. They are similar to static variables in that sense. An example would be a static method to sum the values of all the variables of every instance of a class. For example, if there were a Product class it might have a static method to compute
4641-409: The compiler when a class object is assigned to a class object of the same type. Operator methods define or redefine operator symbols and define the operations to be performed with the symbol and the associated method parameters. C++ example: Some procedural languages were extended with object-oriented capabilities to leverage the large skill sets and legacy code for those languages but still provide
SECTION 50
#17327717895654732-400: 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 the contained files and directories. The FileDescriptor class is a file descriptor that represents a source or sink (destination) of bytes. Typically this is
4823-425: The data of an object. Manager methods are used to initialize and destroy objects of a class, e.g. constructors and destructors. These methods provide an abstraction layer that facilitates encapsulation and modularity . For example, if a bank-account class provides a getBalance() accessor method to retrieve the current balance (rather than directly accessing the balance data fields), then later revisions of
4914-590: 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 support specifying
5005-576: The differences between languages that utilize garbage-collection and languages with manual memory management, the sequence in which they are called is different. An abstract method is one with only a signature and no implementation body . It is often used to specify that a subclass must provide an implementation of the method, as in an abstract class . Abstract methods are used to specify interfaces in some programming languages. [REDACTED] The following Java code shows an abstract class that needs to be extended: The following subclass extends
5096-425: The error tolerant HTML parser that is used for writing various web browsers and web bots. The javax.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. Java (programming language) Java is a high-level , class-based , object-oriented programming language that
5187-621: The feature and StreamType is one of InputStream , OutputStream , Reader , or Writer . The following table shows the sources/destinations supported directly by the java.io package: 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
5278-531: The generated servlet creates the response. Swing is a graphical user interface library for the Java SE platform. It is possible to specify a different look and feel through the pluggable look and feel system of Swing. Clones of Windows , GTK+ , and Motif are supplied by Sun. Apple also provides an Aqua look and feel for macOS . Where prior implementations of these looks and feels may have been considered lacking, Swing in Java SE 6 addresses this problem by using more native GUI widget drawing routines of
5369-596: The heap, such as the Z Garbage Collector (ZGC) introduced in Java 11, and Shenandoah GC, introduced in Java 12 but unavailable in Oracle-produced OpenJDK builds. Shenandoah is instead available in third-party builds of OpenJDK, such as Eclipse Temurin . For most applications in Java, G1GC is sufficient. In prior versions of Java, such as Java 8, the Parallel Garbage Collector was used as the default garbage collector. Having solved
5460-658: The host hardware. End-users commonly use a Java Runtime Environment (JRE) installed on their device for standalone Java applications or a web browser for Java applets . Standard libraries provide a generic way to access host-specific features such as graphics, threading , and networking . The use of universal bytecode makes porting simple. However, the overhead of interpreting bytecode into machine instructions made interpreted programs almost always run more slowly than native executables . Just-in-time (JIT) compilers that compile byte-codes to machine code during runtime were introduced from an early stage. Java's Hotspot compiler
5551-556: The implementation of floating-point arithmetic, and a history of security vulnerabilities in the primary Java VM implementation HotSpot . Developers have criticized the complexity and verbosity of the Java Persistence API (JPA), a standard part of Java EE. This has led to increased adoption of higher-level abstractions like Spring Data JPA, which aims to simplify database operations and reduce boilerplate code. The growing popularity of such frameworks suggests limitations in
SECTION 60
#17327717895655642-400: The implementation of those behaviors to the receiving object. A method in Java programming sets the behavior of a class object. For example, an object can send an area message to another object and the appropriate formula is invoked whether the receiving object is a rectangle , circle , triangle , etc. Methods also provide the interface that other classes use to access and modify
5733-537: The introduction of just-in-time compilation in 1997/1998 for Java 1.1 , the addition of language features supporting better code analysis (such as inner classes, the StringBuilder class, optional assertions, etc.), and optimizations in the Java virtual machine, such as HotSpot becoming Sun's default JVM in 2000. With Java 1.5, the performance was improved with the addition of the java.util.concurrent package, including lock-free implementations of
5824-508: The main class: If a subclass provides an implementation for an abstract method, another subclass can make it abstract again. This is called reabstraction . In practice, this is rarely used. In C#, a virtual method can be overridden with an abstract method. (This also applies to Java, where all non-private methods are virtual.) Interfaces' default methods can also be reabstracted, requiring subclasses to implement them. (This also applies to Java.) Class methods are methods that are called on
5915-455: The memory management problem does not relieve the programmer of the burden of handling properly other kinds of resources, like network or database connections, file handles, etc., especially in the presence of exceptions. The syntax of Java is largely influenced by C++ and C . Unlike C++, which combines the syntax for structured, generic, and object-oriented programming, Java was built almost exclusively as an object-oriented language. All code
6006-535: The message digest algorithm, is included in the java.security package. An implementation of the JDBC API (used to access SQL databases ) is grouped into the java.sql package. The javax.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 Swing
6097-500: The meta-model allows the developer to dynamically alter the object model at run time: e.g., to create new classes, redefine the class hierarchy, modify properties, etc. Special methods are very language-specific and a language may support none, some, or all of the special methods defined here. A language's compiler may automatically generate default special methods or a programmer may be allowed to optionally define special methods. Most special methods cannot be directly called, but rather
6188-525: The name of the class (e.g. Class.forName("mypackage.MyClass") ). With a Class object, member Method , Constructor , or Field objects can be obtained using the symbolic name of the member. For example: Method , Constructor , and Field objects can be used to dynamically access the represented member of the class. For example: The java.lang.reflect package also provides an Array class that contains static methods for creating and manipulating array objects, and since J2SE 1.3,
6279-560: The name was changed to Java Platform, Standard Edition or Java 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 the Java version history . Starting with J2SE 1.4 (Merlin), Java SE has been developed under
6370-450: The package are primarily stream-oriented ; however, a class for random access files is also provided. The central classes in the package are InputStream and OutputStream , which are abstract base classes for reading from and writing to byte streams , respectively. The related classes Reader and Writer are abstract base classes for reading from and writing to character streams, respectively. The package also has
6461-410: The package are: The java.net package provides special IO routines for networks, allowing HTTP requests, as well as other common transactions. The java.text package implements parsing routines for strings and supports various human-readable languages and locale-specific parsing. Data structures that aggregate objects are the focus of the java.util package. Included in the package
6552-496: The platforms. The platforms are: The classes in the Java APIs are organized into separate groups called packages . Each package contains a set of related interfaces , classes, subpackages and exceptions . Sun also provided an edition called Personal Java that has been superseded by later, standards-based Java ME configuration-profile pairings. One design goal of Java is portability , which means that programs written for
6643-451: The program and can be read by some integrated development environments (IDEs) such as Eclipse to allow developers to access documentation within the IDE. The following is a simple example of a "Hello, World!" program that writes a message to the standard output : Java applets are programs embedded in other applications, mainly in web pages displayed in web browsers. The Java applet API
6734-448: The properties of an object; this is known as encapsulation . Encapsulation and overriding are the two primary distinguishing features between methods and procedure calls. Method overriding and overloading are two of the most significant ways that a method differs from a conventional procedure or function call. Overriding refers to a subclass redefining the implementation of a method of its superclass. For example, findArea may be
6825-419: 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 , and constructors can all be discovered and used at runtime. Reflection is supported by metadata that
6916-472: The reference type is phantom), and the clear() method to clear the reference. The java.lang.ref also defines the class ReferenceQueue , which can be used in each of the applications discussed above to keep track of objects that have changed reference type. When a Reference is created it is optionally registered with a reference queue. The application polls the reference queue to get references that have changed reachability state. Reflection
7007-427: The same code can implement a more complex mechanism for balance retrieval (e.g., a database fetch), without the dependent code needing to be changed. The concepts of encapsulation and modularity are not unique to object-oriented programming. Indeed, in many ways the object-oriented approach is simply the logical extension of previous paradigms such as abstract data types and structured programming . A constructor
7098-481: The second parameter is the Method 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. The invoke() method returns an Object result that contains the result returned to the code that called the proxy interface method. The java.io package contains classes that support input and output . The classes in
7189-527: The selling of licenses for specialized products such as the Java Enterprise System. On November 13, 2006, Sun released much of its Java virtual machine (JVM) as free and open-source software (FOSS), under the terms of the GPL-2.0-only license. On May 8, 2007, Sun finished the process, making all of its JVM's core code available under free software /open-source distribution terms, aside from
7280-481: The specifications of the Java Community Process , Sun had relicensed most of its Java technologies under the GPL-2.0-only license. Oracle offers its own HotSpot Java Virtual Machine, however the official reference implementation is the OpenJDK JVM which is free open-source software and used by most developers and is the default JVM for almost all Linux distributions. As of September 2024 , Java 23
7371-468: The standard JPA implementation's ease-of-use for modern Java development. The Java Class Library is the standard library , developed to support application development in Java. It is controlled by Oracle in cooperation with others through the Java Community Process program. Companies or individuals participating in this process can influence the design and development of the APIs. This process has been
7462-409: The type system of Java was proven unsound in that it is possible to use generics to construct classes and methods that allow assignment of an instance one class to a variable of another unrelated class. Such code is accepted by the compiler, but fails at run time with a class cast exception. Criticisms directed at Java include the implementation of generics, speed, the handling of unsigned numbers,
7553-434: The underlying computer architecture . The syntax of Java is similar to C and C++ , but has fewer low-level facilities than either of them. The Java runtime provides dynamic capabilities (such as reflection and runtime code modification) that are typically not available in traditional compiled languages. Java gained popularity shortly after its release, and has been a very popular programming language since then. Java
7644-401: The underlying native system. This package contains 22 of 32 Error classes provided in JDK 6. The main classes and interfaces in java.lang are: Classes in java.lang are automatically imported into every source file . The java.lang.ref package provides more flexible types of references than are otherwise available, permitting limited interaction between the application and
7735-571: The underlying platforms. JavaFX is a software platform for creating and delivering desktop applications , as well as rich web applications that can run across a wide variety of devices. JavaFX is intended to replace Swing as the standard GUI library for Java SE , but since JDK 11 JavaFX has not been in the core JDK and instead in a separate module. JavaFX has support for desktop computers and web browsers on Microsoft Windows , Linux , and macOS . JavaFX does not have support for native OS look and feels. In 2004, generics were added to
7826-625: 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 by certificate authorities . Included 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. The APIs in java.beans are intended for use by
7917-417: The web service methods for the actual business logic. JavaServer Pages ( JSP ) are server-side Java EE components that generate responses, typically HTML pages, to HTTP requests from clients . JSPs embed Java code in an HTML page by using the special delimiters <% and %> . A JSP is compiled to a Java servlet , a Java application in its own right, the first time it is accessed. After that,
8008-440: Was deprecated with the release of Java 9 in 2017. Java servlet technology provides Web developers with a simple, consistent mechanism for extending the functionality of a Web server and for accessing existing business systems. Servlets are server-side Java EE components that generate responses to requests from clients . Most of the time, this means generating HTML pages in response to HTTP requests, although there are
8099-665: Was initially called Oak after an oak tree that stood outside Gosling's office. Later the project went by the name Green and was finally renamed Java , from Java coffee , a type of coffee from Indonesia . Gosling designed Java with a C / C++ -style syntax that system and application programmers would find familiar. Sun Microsystems released the first public implementation as Java 1.0 in 1996. It promised write once, run anywhere (WORA) functionality, providing no-cost run-times on popular platforms . Fairly secure and featuring configurable security, it allowed network- and file-access restrictions. Major web browsers soon incorporated
8190-689: Was renamed J2SE. In 2006, for marketing purposes, Sun renamed new J2 versions as Java EE , Java ME , and Java SE , respectively. In 1997, Sun Microsystems approached the ISO/IEC JTC 1 standards body and later the Ecma International to formalize Java, but it soon withdrew from the process. Java remains a de facto standard , controlled through the Java Community Process . At one time, Sun made most of its Java implementations available without charge, despite their proprietary software status. Sun generated revenue from Java through
8281-625: Was the third most popular programming language in 2022 according to GitHub . Although still widely popular, there has been a gradual decline in use of Java in recent years with other languages using JVM gaining popularity. Java was originally developed by James Gosling at Sun Microsystems . It was released in May 1995 as a core component of Sun's Java platform . The original and reference implementation Java compilers , virtual machines, and class libraries were originally released by Sun under proprietary licenses . As of May 2007, in compliance with
#564435