Java Platform, Standard Edition or Java SE is a widely used platform for programming in the Java language. It is the Java Platform used to deploy portable applications for general use. In practical terms, Java SE consists of a virtual machine, which must be used to run Java programs, together with a set of libraries (or "packages") needed to allow the use of file systems, networks, graphical interfaces, and so on, from within those programs.
Nomenclature, standards and specifications
Java SE was known as Java 2 Platform, Standard Edition or J2SE from version 1.2 until version 1.5. The "SE" is used to distinguish the base platform from Java EE and Java ME. The "2" was originally intended to emphasize the major changes introduced in version 1.2, but was removed in version 1.6. The naming convention has been changed several times over the Java version history. Starting with J2SE 1.4 (Merlin), Java SE has been developed under the Java Community Process. JSR 59 was the umbrella specification for J2SE 1.4 and JSR 176 specified J2SE 5.0 (Tiger). Java SE 6 (Mustang) was released under JSR 270.
Java Platform, Enterprise Edition is a related specification which includes all of the classes in Java SE, plus a number which are more useful to programs which run on servers as opposed to workstations. Java Platform, Micro Edition is a related specification intended to provide a certified collection of Java APIs for the development of software for small, resource-constrained devices such as cell phones, PDAs and set-top boxes.
The JRE and JDK are the actual files that are downloaded and installed on a computer in order to run or develop java programs, respectively.
General purpose packages
java.lang
The Java package
java.langcontains 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 the underlying native system. This package contains 22 of 32Errorclasses provided in JDK 6.The main classes in
java.langare:
Object– the class that is the root of every class hierarchy.Enum– the base class for enumeration classes (as of J2SE 5.0).Class– the class that is the root of the Java reflection system.Throwable– the class that is the base class of the exception class hierarchy.Error,Exception, andRuntimeException– the base classes for each exception type.Thread– the class that allows operations on threads.String– the class for strings and string literals.StringBufferandStringBuilder– classes for performing string manipulation (StringBuilderas of J2SE 5.0).Comparable– the interface that allows generic comparison and ordering of objects (as of J2SE 1.2).Iterable– the interface that allows generic iteration using the enhancedforloop (as of J2SE 5.0).ClassLoader,Process,Runtime,SecurityManager, andSystem– classes that provide "system operations" that manage the dynamic loading of classes, creation of external processes, host environment inquiries such as the time of day, and enforcement of security policies.MathandStrictMath– classes that provide basic math functions such as sine, cosine, and square root (StrictMathas of J2SE 1.3).- The primitive wrapper classes that encapsulate primitive types as objects.
- The basic exception classes thrown for language-level and other common exceptions.
Classes in
java.langare automatically imported into every source file.java.lang.ref
The
java.lang.refpackage provides more flexible types of references than are otherwise available, permitting limited interaction between the application and 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 a more expressive system of reference than most other garbage-collected programming languages, which allows for special behavior for garbage collection. A normal reference in Java is known as a "strong reference." The
java.lang.refpackage defines three other types of references — soft, weak, and phantom references. Each type of reference is designed for a specific use.
- A
SoftReferencecan be used to implement a cache. 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 will only be garbage collected when free memory is low, but again, it is at the discretion of the garbage collector. Semantically, a soft reference means "keep this object unless the memory is needed."
- A
WeakReferenceis 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 will be garbage collected during 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 the string intern pool. Semantically, a weak reference means "get rid of this object when nothing else references it."
- A
PhantomReferenceis used to reference objects that have been marked for garbage collection and have been finalized, 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 the
Referenceclass which provides theget()method to return a strong reference to the referent object (ornullif the reference has been cleared or if the reference type is phantom), and theclear()method to clear the reference.The
java.lang.refalso 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 aReferenceis 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
Reflection is a constituent of the Java API which enables Java code to examine and "reflect" upon Java components at runtime and to use the reflected members. Classes in the
java.lang.reflectpackage, along withjava.lang.Classandjava.lang.Packageaccommodate applications such as debuggers, interpreters, object inspectors, class browsers, and services such as object serialization and JavaBeans 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, and constructors can all be discovered and used at runtime. Reflection is supported by metadata that the JVM has about the program.
Techniques
There are two 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
Discovery typically starts with an object and calling the
Object.getClass()method to get the object'sClass. TheClassobject has several methods for discovering the contents of the class, for example:
getMethods()– returns an array ofMethodobjects representing all the public methods of the class or interfacegetConstructors()– returns an array ofConstructorobjects representing all the public constructors of the classgetFields()– returns an array ofFieldobjects representing all the public fields of the class or interfacegetClasses()– returns an array ofClassobjects representing all the public classes and interfaces t
InputStream (Java Platform SE 7 b76)
Please note that this documentation is not final and is subject to change.
java.io.InputStream Java Source 1.5.0
001 /* 002 * @(#)InputStream.java 1.45 04/02/19; 003 * 004 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 005 * SUN PROPRIETARY/CONFIDENTIAL.
InputStream (Java 2 Platform SE 5.0)
public abstract class InputStream extends Object implements Closeable. This abstract class is the superclass of all classes representing an input stream of bytes.
InputStream (Java Platform SE 6)
This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and ...
InputStream | Android Developers
Class Overview. The base class for all input streams. An input stream is a means of reading data from a source in a byte-wise manner. Some input streams also support marking a ...
InputStream (Java Platform SE 6)
public abstract class InputStream extends Object implements Closeable. This abstract class is the superclass of all classes representing an input stream of bytes.
java.io: InputStream.java
1 /* 2 * Copyright 1994-2006 Sun Microsystems, Inc. All Rights Reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
Java Programming - Java - InputStream - Weird Characters in the Output ...
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream(),"US-ASCII")); BufferedWriter out=new BufferedWriter(new FileWriter(tmp_file));
java.net Forums : InputStream from Runtime.exec hangs ...
This is strange, I discovered that if I run a process and get an input stream Runtime.getRuntime().exec().getInputStream() - I can read only the very first line from it or ...
Java Programming - InputStream error
Hi, I have a java code which had a method to read from files. Since I have now decided to package the files it was reading from and my code as a jar I am trying to convert the ...