Notes about the Java Programming Language

This WWW document contains a large amount of information about the Java programming language and the standard class libraries.

General Information


  1. Key features of the Java programming language
  2. Comparison with C++
  3. Brief Glimpse at Libraries
  4. JDK Tool Suite


  1. Lexical Elements of Java
  2. Structure of a Main Program
  3. Executing a Java Program
  4. Names
  5. Command Line
  6. Larger Programs
  7. Primitive Data Types and Wrapper Classes

Expressions, Declarations, Statements

  1. Introduction
  2. Expressions
  3. Declarations
  4. Arrays
  5. Statements

Bytecode, JVM, JIT, Class Path

  1. Bytecode
  2. Class Path
  3. Bytecode Verification
  4. Controlling a JIT

Simple Programs


  1. Classes as Data Structures
  2. Methods (Subprocedures)
  3. Classes and Inheritance
  4. Abstract Classes
  5. Modifiers
  6. Inferfaces
  7. Nested Classes


  1. An example:,
  2. The need for generics.
    1. Using objects for universal polymorphism:
    2. Using generics
  3. Generic methods:
  4. Generic array instantiation is not permitted:
  5. Generic methods (how reverseOrder is implemented:
  6. When to use wildcard in generics:
  7. Type of max: See also FAQ 104 by Langer.

Collection Classes

  1. Needs revision
  2. Wrapper Implementations
  3. Iterators

Example Java Programs

How to get some simple chores done: random numbers, (we looked at number formatting earlier) date formatting, properties, string tokenizer, stream tokenizer, and enumeration types.

Packages in Java

Exception handling

  1. Try/Catch Statment and Predefined Exceptions
  2. Exceptions as Values
  3. Catch or Declare
  4. Throwables in the Core Libraries
  5. Finally Clause
  6. Performance Considerations
  7. Recursion

Jar Files

  1. Introduction and Purpose
  2. Using the Jar Tool
  3. Executing Jar Files
  4. Sealed Packages
  5. Package Versioning
  6. Java Extensions
  7. Reading and Writing Jar Files in Java

Numeric Computing with Java

The IEEE 754 standard permits additional precision to be used when calculating the result of function. For example, the Intel x86 and the IBM PowerPC do this by default. Numeric programs written in Java and run on different computers might get slightly different results depending of the choice of precision when calculating intermediate results. The keyword strictfp in Java permits the programmer to obtain control over the numeric calculations of the underlying machine. It says to use standard precision and not extended precision.

Within an expression that is not FP-strict, some leeway is granted for an implementation to use an extended exponent range to represent intermediate results; the net effect, roughly speaking, is that a calculation might produce "the correct answer" in situations where exclusive use of the float value set or double value set might result in overflow or underflow.
Improving Java for Numerical Computation, 1998.

How Java's Floating-Point Hurts Everyone Everywhere by Kahn and Darcy, 1998.

Concurrent Programming with Java Threads

  1. Thread Creation
  2. Passing Information, Priority, Deamon
  3. Update Anomolies and Synchronization
  4. Wait/Notify
  5. Two Phase Locking
  6. Concurrency Utilities
  7. Miscellaneous
  8. Example: Asynchronous IO


  1. Locales
  2. Character Encodings
  3. Input Method Editors


JNLP. Deploying Software with JNLP and Java Web Start, August 2002.



  1. Serialization
  2. Reflection and Dynamic Loading
  3. JDI (Java Debug Interface)
  4. Java Beans

Garbage Collection, References, and Performance Tuning

  1. Tuning Garbage Collection with the 5.0 JVM
void method () {
   Image big = new Image ();
   // use big
   big = null;   /* pointless; will be reclaimed by collector anyway
On the other hand, be sure to set references to null in long-lived data structures.
        public class Stack {
               private Object stk[] = new Object[100];

                private int top = 0;

                public void push(Object p)                {
                        stk[top++] = p;

                public Object pop()                {
                   Object p = stk[top-1];
                   stk[top-1] = null;
                  return p;


Networking in Java

Remote Method Invocation




IDL (interface definition language), CORBA (common object request broker architecture) developed by the Object Management Group, headquarted in Massachusetts. OMG is a consortium of over 700 companies.

Like RMI it has stubs and skeletons.

How CORBA Sends Information


Similar CGI and to Microsoft's ISAPI and ASP and Netscape's NSAPI.
Intro to The Common Gateway Interface
An overview by NCSA.
NSAPI (Netscape Server API)
Part of Netscape's server software products.
ISAPI (Internet Server API)
Developed by Progress Software and Microsoft.
Spyglass Server Application Development Interface
Apache API

Servlets are modules of Java code that run in a server application (hence the name "Servlets", similar to "Applets" on the client side) to answer client requests. Servlets are not tied to a specific client-server protocol but they are most commonly used with HTTP and the word "Servlet" is often used in the meaning of "HTTP Servlet".

Servlets make use of the Java standard extension classes in the packages javax.servlet (the basic Servlet framework) and javax.servlet.http (extensions of the Servlet framework for Servlets that answer HTTP requests).

Not part of the JDK

Since Servlets are written in the highly portable Java language and follow a standard framework, they provide a means to create sophisticated server extensions in a way that independent of the server and of the operating system.

Typical uses for HTTP Servlets include:

Servlet lifecyle: init(), service(), destroy().

Forms Processing in Servlet

Input text:
Input text (with default value):
Radio buttons: KANU KERA WFIT
Checkbox or toggle: Send money?
Select (multiple):

Button to submit the form:
Button to clear the values in the form:

Java and XML


Available HTTP servers that support servlets or jsp.


Looks easy and well documented, but slow.



Java 3D

Canvas3D is a subclass of java.awt.Canvas and hence the display of Java 3D is in a "heavyweight" component that does not mix well with Java Swing "lightweight" components.





JavaSpaces technology is tool for coordinating processes into a distributed application. It does rely on passing message between processes or invoking methods on remote objects like most forms of distributed programming. Instead an application is viewed as a collection of processes cooperating via the flow of objects into and out of one or more spaces. This space-based model of distributed computing has its roots in the Linda coordination language developed by Dr. David Gelernter at Yale University. A space is a shared, network-accessible repository for objects. Processes use the repository as a persistent object storage and exchange mechanism; instead of communicating directly, they coordinate by exchanging objects through spaces. Processes perform simple operations to write new objects into a space, take objects from a space, or read (make a copy of) objects in a space. When taking or reading objects, processes use a simple value-matching lookup to find the objects that matter to them. If a matching object isn't found immediately, then a process can wait until one arrives. Unlike conventional object stores, processes don't modify objects in the space or invoke their methods directly--while there, objects are just passive data. To modify an object, a process must explicitly remove it, update it, and reinsert it into the space.
Java Spaces

Ryan Stansifer <>
Last modified: Tue Nov 8 18:52:26 EST 2011