The Evolution of Java: A Historical Perspective

Roman Glushach
7 min readAug 11, 2023

--

Java History

Java is one of the most popular and widely used programming languages in the world. It is a general-purpose, object-oriented, platform-independent, and high-performance language that can run on any device that supports a Java virtual machine (JVM).

History

The story of Java begins in June 1991, when a small team of engineers at Sun Microsystems, led by James Gosling, started a project called Green. The goal of the project was to develop a programming language for consumer electronic devices, such as smart TVs, set-top boxes, and handheld controllers. These devices needed a language that was simple, robust, portable, and secure, as they had limited memory and processing power, and had to communicate with each other over different networks.

The team initially named the language Greentalk, with the file extension .gt. Later, they renamed it to Oak, after an oak tree that stood outside Gosling’s office. Oak was influenced by several other languages, such as C, C++, Smalltalk, Lisp, and Ada. However, Oak was not designed for the web, which was emerging as a new platform for distributed computing and information sharing.

The Rise of Java

In 1993, the Green team demonstrated their technology to Time Warner, who was interested in using it for interactive TV. However, the cable industry was not ready for such an advanced system, and the deal fell through. The team then shifted their focus to the web, which offered a more promising opportunity for their language.

The team realized that Oak could be used to create dynamic and interactive web pages that could run on any browser that supported a JVM. They created a prototype browser called WebRunner, later renamed HotJava, that could execute Oak applets (small programs) embedded in HTML pages. They also decided to rename Oak to Java, as there was already another language called Oak. The name Java was chosen because it was simple, unique, fun to say, and evoked the idea of coffee, which the team consumed a lot during their long working hours. Java is not an acronym; it is just a name.

In 1995, Sun Microsystems officially announced Java at the SunWorld conference. The same year, Netscape Communications agreed to include Java support in their popular Netscape Navigator browser. This gave Java a huge boost in popularity and exposure, as millions of web users could now access Java applets on their browsers. Time magazine called Java one of the Ten Best Products of 1995.

The Evolution of Java

Since its first release in 1995, Java has undergone many changes and improvements. Sun Microsystems established the Java Community Process (JCP) in 1998 to allow other companies and organizations to participate in the development and standardization of Java. The JCP oversees the creation and revision of Java specifications, which define the syntax and semantics of the language, as well as its libraries and APIs (application programming interfaces).

The first version of Java was JDK (Java Development Kit) 1.0, which provided the basic features of the language, such as classes, objects, inheritance, polymorphism, exceptions, threads, and garbage collection. It also included some core libraries for input/output (I/O), networking, graphics, and user interface components.

Since then, many new versions of Java have been released with new features and enhancements.

The Future of Java

Java is still a vibrant and evolving language that continues to attract developers and users around the world. It is used for a wide range of applications, such as web development, enterprise systems, mobile development, desktop applications, embedded systems, cloud computing, big data, machine learning, and more.

Main Java Version’s Features

JDK 1.1

Inner classes

class Outer {
int x = 10;
class Inner {
int y = 20;
void display() {
System.out.println("x = " + x + ", y = " + y);
}
}
}

Outer outer = new Outer();
Outer.Inner inner = outer.new Inner();
inner.display(); // prints x = 10, y = 20

JDBC

import java.sql.*;

public class JdbcExample {
public static void main(String[] args) {
try {
// Load the driver class
Class.forName("org.h2.Driver");

// Establish the connection
Connection con = DriverManager.getConnection("jdbc:h2:~/test", "sa", "");

// Create the statement object
Statement stmt = con.createStatement();

// Execute the query
ResultSet rs = stmt.executeQuery("select * from emp");

// Print the result
while (rs.next()) {
System.out.println(rs.getInt(1) + " " + rs.getString(2) + " " + rs.getInt(3));
}

// Close the resources
rs.close();
stmt.close();
con.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

RMI and Serialization

import java.rmi.*;
import java.rmi.server.*;

// Define a remote interface
public interface Hello extends Remote {
String sayHello() throws RemoteException;
}

// Implement the remote interface
public class HelloImpl extends UnicastRemoteObject implements Hello {

public HelloImpl() throws RemoteException {}

public String sayHello() throws RemoteException {
return "Hello, world!";
}
}

// Create and register the remote object
public class HelloServer {
public static void main(String[] args) {
try {
HelloImpl obj = new HelloImpl();
Naming.rebind("Hello", obj);
System.out.println("HelloServer ready.");
} catch (Exception e) {
e.printStackTrace();
}
}
}

// Invoke the remote method
public class HelloClient {
public static void main(String[] args) {
try {
Hello obj = (Hello) Naming.lookup("Hello");
String message = obj.sayHello();
System.out.println(message);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Reflection

import java.lang.reflect.*;

public class ReflectionExample {
public static void main(String[] args) {
try {
Class<?> cls = Class.forName("Person");
Constructor<?> cons = cls.getConstructor();
// Create a new instance of Person using the constructor
Object obj = cons.newInstance();

// Get the name field of Person
Field nameField = cls.getDeclaredField("name");

// Make the name field accessible
nameField.setAccessible(true);
nameField.set(obj, "Alice");
String name = (String) nameField.get(obj);
System.out.println(name); // prints Alice

Method setAgeMethod = cls.getMethod("setAge", int.class);
setAgeMethod.invoke(obj, 25);

Method getAgeMethod = cls.getMethod("getAge");
int age = (int) getAgeMethod.invoke(obj);
System.out.println(age); // prints 25
} catch (Exception e) {
e.printStackTrace();
}
}
}

JDK 1.2

strictfp

public strictfp class StrictfpDemo {
float f = 9.678f;
strictfp public void displayValue() {
System.out.println(f);
}
}

Collections

import java.util.ArrayList;
import java.util.Collections;

public class CollectionsExample {
public static void main(String[] args) {
ArrayList<Integer> numbers = new ArrayList<Integer>();
numbers.add(5);
numbers.add(3);
numbers.add(4);

System.out.println("Before sorting: " + numbers);
Collections.sort(numbers);
System.out.println("After sorting: " + numbers);
}
}

JDK 1.4

Regular Expressions

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexExample {
public static void main(String[] args) {
String text = "The quick brown fox jumps over the lazy dog";
String patternString = "fox";
Pattern pattern = Pattern.compile(patternString);
Matcher matcher = pattern.matcher(text);

while (matcher.find()) {
int start = matcher.start();
int end = matcher.end();
String match = text.substring(start, end);
System.out.println("Matched: " + match);
}
}
}

Exception Chaining

public class ExceptionChainingExample {
public static void main(String[] args) {
try {
// Cause exception
int a = 10 / 0;
} catch (ArithmeticException e) {
// Wrap the exception in a new exception
throw new RuntimeException("An error occurred", e);
}
}
}

Java SE 5

Generics

class GenericsClass<T> {
// variable of T type
private T data;

public GenericsClass(T data) {
this.data = data;
}

// method that returns T type variable
public T getData() {
return this.data;
}
}

// usage
GenericsClass<Integer> intObj = new GenericsClass<>(5);
GenericsClass<String> stringObj = new GenericsClass<>("Java");

Metadata: also called annotations

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
@interface MyAnnotation {
String value();
}

@MyAnnotation("This is an example annotation")
public class MyClass {
public static void main(String[] args) {
MyClass myClass = new MyClass();
Class<?> c = myClass.getClass();
MyAnnotation annotation = c.getAnnotation(MyAnnotation.class);
System.out.println(annotation.value());
}
}

Autoboxing/Unboxing

List<Integer> list = new ArrayList<>();
// Autoboxing: int is automatically converted to Integer
list.add(5);
// Unboxing: Integer is automatically converted to int
int num = list.get(0);

Enumerations

public enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY
}

Varargs

public class VarargsExample {
public static void printNumbers(int... numbers) {
for (int number : numbers) {
System.out.println(number);
}
}

public static void main(String[] args) {
printNumbers(1, 2, 3, 4, 5);
}
}

Enhanced for each loop


int[] numbers = {1, 2, 3, 4, 5};
for (int number : numbers) {
System.out.println(number);
}

Static imports

import static java.lang.Math.PI;

Java SE 7

Strings in switch


String dayOfWeek = "Monday";
switch (dayOfWeek) {
case "Monday":
typeOfDay = "Start of work week";
break;
default:
throw new IllegalArgumentException("Not implemented day of the week: " + dayOfWeek);
}

try-with-resources


try (BufferedReader reader = new BufferedReader(new FileReader("file.txt"))) {
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}

Java SE 8

Date and Time API


LocalDate date = LocalDate.now();
System.out.println("Current date: " + date);

LocalTime time = LocalTime.now();
System.out.println("Current time: " + time);

LocalDateTime dateTime = LocalDateTime.now();
System.out.println("Current date and time: " + dateTime);

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String formattedDateTime = dateTime.format(formatter);
System.out.println("Formatted date and time: " + formattedDateTime);

Java SE 12

Switch Expressions


Day day = Day.MONDAY;
int numLetters = switch (day) {
case MONDAY, FRIDAY, SUNDAY -> 6;
case TUESDAY -> 7;
default -> throw new IllegalStateException("Not supported day: " + day);
};

Java SE 14

instanceof

if (obj instanceof String s) {
System.out.println(s.length());
}

Records

record Point(int x, int y) { }
Point p = new Point(3,4);
System.out.println(p.x());

Java SE 15

Sealed Classes

public abstract sealed class Shape
permits Circle, Rectangle, Square { }

Java SE 17

switch pattern matching

Object o = "Hello world";
return switch (o) {
case null -> "Null";
case String s -> String.format("String %s", s);
case Integer i && i > 0 -> String.format("positive int %d", i);
case Integer i && i == 0 -> String.format("zero int %d", i);
case Integer i && i < 0 -> String.format("negative int %d", i);
default -> o.toString();
};
};

Java SE 19

switch pattern matching extended by including record patterns

record Rectangle(int x, int y, int w, int h) {}

int area(Object o) {
if (o instanceof Rectangle(int x, int y, int w, int h)) {
return w * h;
}
return 0;
}

Java SE 21

Unnamed classes

void main() {
System.out.println("Hello, World!");
}

// instead of
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

Conclusion

Java is a programming language that has a rich and fascinating history. It started as a project for interactive television, but it became a revolutionary technology for web programming. It has evolved over time to adapt to new challenges and opportunities, and it has maintained its popularity and relevance in the software industry.

--

--

Roman Glushach

Senior Software Architect & Engineer Manager at Freelance