← the guideThe Web Opens

§ 02 — Eras · 1995

Java

write once, run anywhere — the enterprise’s lingua franca

Left: era context, features, and the 101 hello. Right: 3 core concepts, 3 deeper 201 lessons, the factorial specimen, and where Java lives today — each column scrolls on its own.

creators
James Gosling, Sun, 1995
status
alive (dominant) · enterprise backends, Android, big data
lineage
← C++→ C#

The problem it solves

C++ was unsafe in practice and unportable in deployment. The JVM made garbage collection and portability platform promises.

The problem it carries

Ceremony — the factory-abstract-singleton years — verbose types, and a runtime footprint that starts in megabytes.

Key features

the JVM
A virtual machine with garbage collection, JIT compilation and a security sandbox.
managed memory
Memory safety without manual management — and without a garbage-collection pause-free miracle.
interfaces and generics
Contracts as first-class types, and compile-time genericity with erasure behind it.
checked exceptions
Errors declared in the signature, so callers cannot forget them.

101 — hello, world

Session one is the smallest program that still counts as speaking Java: what every tutorial prints first, in the dialect that mattered when the language arrived (1995).

the first program1995
public class Hello {
  public static void main(String[] args) {
    System.out.println("Hello, world");
  }
}

101First contact — hello world and 3 ideas that define how Java reads. 201 — 3 lessons on mechanisms you meet after the factorial specimen: the sharp edges practitioners actually use.

101 — core concepts

3 fragments, each naming a habit of mind in Java. Read the note, then the code — together they are the 101 in one sitting.

01 — classes & interfaces

Contracts by interface, behavior by class — the shape of enterprise code for decades.

interface Dockable {
  void dock(String port);
}

class Ship implements Dockable {
  public void dock(String port) { ... }
}

02 — the JVM

The virtual machine: GC, JIT, portability — a platform that outlived its language’s fashions.

// compile once
javac Hello.java
// run anywhere the JVM lives
java Hello

03 — generics & streams

Modern Java is functional-adjacent: lambdas and streams over the old ceremony.

int total = ships.stream()
  .mapToInt(Ship::tons)
  .sum();

201 — going deeper

The 201 assumes you have read the 101 and the specimen. Each lesson is one mechanism — what it is for, how it looks in code, and the trap or payoff that makes Java distinctive at scale.

  1. generics and erasure
  2. streams and functional pipelines
  3. concurrency and the JVM

generics and erasure

Type parameters are checked at compile time and erased at runtime — which is why you cannot ask a List what it holds without a cast.

List<String> names = new ArrayList<>();
names.add("Perch");
String first = names.get(0);   // checked, not stored

streams and functional pipelines

A stream is a lazy pipeline over data: filter, map, collect, with short-circuiting and parallelism for free.

int total = ships.stream()
  .filter(s -> s.tons() > 20)
  .mapToInt(Ship::tons)
  .sum();

concurrency and the JVM

Threads, executors, CompletableFuture and (since 21) virtual threads — and beneath them, the class loader, the JIT and the garbage collector.

try (var scope = new StructuredTaskScope.ShutdownOnFailure()) {
  scope.fork(() -> fetchCrew());
  scope.join().throwIfFailed();
}

The specimen — factorial

The virtual machine: one binary, any machine — garbage collection and sandboxing as platform promises. Write once, run anywhere; eventually, run everywhere.

the virtual machine1995
public class Hello {
  public static void main(String[] args) {
    System.out.println("ahoy");
  }
}

Run it today

installbrew install openjdk

runjava fact.java

Where it is now

Banks, airlines, Android (via the JVM lineage), Hadoop/Kafka/Elasticsearch — the back office of the internet.