Latest in branch Java SE 5
5.0u85
Released 14 Apr 2015
(11 years ago)
SoftwareJava/Java SE
BranchJava SE 5
Status
End of life
Class file version49.0
Initial release5.0
30 Sep 2004
(21 years ago)
Latest release5.0u85
14 Apr 2015
(11 years ago)
End of
premier support
Oct 2009
(Ended 16 years, 6 months ago)
End of
extended support
Unavailable
Release noteshttps://www.oracle.com/java/technologies/javase/advancedv5-support-relnotes.html
Documentationhttps://docs.oracle.com/javase/1.5.0/docs/
Downloadhttps://www.oracle.com/java/technologies/java-archive-javase5-downloads.html
Java/Java SE Java SE 5 ReleasesView full list

What Is New in Java 5

Java 5 (JDK 1.5) was a monumental release that fundamentally changed how developers write Java code. It introduced major language features and API enhancements that boosted productivity and expressiveness.

Category Key Changes
Language Features Generics, Enhanced for Loop, Autoboxing/Unboxing, Enums, Varargs, Static Import, Annotations
Core Libraries Concurrency Utilities (java.util.concurrent), Formatter class, Scanner class
Virtual Machine Monitoring and Management Support (JMX), JVM Tool Interface (JVM TI)
Deployment Java Web Start and Applet improvements

How did Java 5 change the language syntax?

Java 5 introduced several syntactic enhancements that made code more concise and less error-prone. These features reduced boilerplate and allowed developers to express intent more clearly.

Generics

Generics provided compile-time type safety for collections. This eliminated the need for explicit casts and reduced ClassCastException risks at runtime.

// Pre-Java 5
List list = new ArrayList();
list.add("hello");
String s = (String) list.get(0);

// Java 5 with Generics
List<String> list = new ArrayList<String>();
list.add("hello");
String s = list.get(0); // No cast needed

Enhanced for Loop

The enhanced for loop simplified iteration over arrays and collections, removing the need for manual index management.

for (String element : collection) {
    System.out.println(element);
}

Autoboxing and Unboxing

Automatic conversion between primitive types and their corresponding wrapper types eliminated tedious manual conversion code.

Integer i = 10; // Autoboxing
int j = i;      // Unboxing

Enums

Enums provided a type-safe way to define constant sets, replacing the traditional pattern of public static final int constants.

public enum Color {
    RED, GREEN, BLUE
}

Varargs

Variable arguments simplified methods that accept a variable number of parameters, eliminating the need to create arrays manually.

void printAll(String... strings) {
    for (String s : strings) {
        System.out.println(s);
    }
}

Static Import

Static import allowed direct access to static members without qualifying them with class names, making code more readable.

import static java.lang.Math.PI;
// Later in code
double circumference = 2 * PI * radius;

Annotations

Annotations added metadata to Java code, enabling declarative programming styles that would later power frameworks like Spring.

@Override
public String toString() {
    return "This is an override";
}

What concurrency improvements did Java 5 introduce?

The java.util.concurrent package was arguably the most significant API addition in Java 5. It provided robust, high-performance threading utilities that replaced error-prone manual synchronization.

Executor Framework

The Executor framework abstracted thread management, allowing developers to focus on tasks rather than thread mechanics.

ExecutorService executor = Executors.newFixedThreadPool(5);
executor.execute(new RunnableTask());
executor.shutdown();

Concurrent Collections

Thread-safe collections like ConcurrentHashMap provided better performance than synchronized wrappers by using advanced locking techniques.

Map<String, Integer> map = new ConcurrentHashMap<>();

Synchronizers

Classes like CountDownLatch, Semaphore, and CyclicBarrier provided common synchronization patterns out of the box.

CountDownLatch latch = new CountDownLatch(3);
// Multiple threads count down, one thread awaits
latch.await();

Atomic Variables

The java.util.concurrent.atomic package provided classes for lock-free, thread-safe programming on single variables.

AtomicInteger counter = new AtomicInteger();
counter.incrementAndGet();

What monitoring and management capabilities were added?

Java 5 significantly enhanced the JVM's observability through built-in monitoring and management support. This was crucial for production system troubleshooting.

JMX Support

The Java Management Extensions (JMX) API and infrastructure became a standard part of the platform, enabling remote monitoring and management of the JVM and applications.

// MBean interface and implementation became standard
public interface SystemConfigMBean {
    void setThreadCount(int count);
    int getThreadCount();
}

JVM Tool Interface

The JVM Tool Interface (JVM TI) replaced the older JVMPI and JVMDI interfaces, providing a more capable foundation for profiling and debugging tools.

Monitoring and Management Console

The JConsole tool was introduced as a graphical interface for monitoring compliant JVMs, providing real-time insights into memory usage, thread activity, and GC behavior.

How did deployment improve in Java 5?

Java 5 made significant strides in application deployment, particularly for Java Web Start and applets, improving both user experience and security.

Java Web Start Enhancements

Java Web Start received improved support for handling multiple JRE versions, better integration with browsers, and enhanced security controls for launching applications.

Applet Improvements

Applets benefited from new JavaScript communication capabilities, allowing better interaction with web pages, and improved plugin reliability.

Versioned Extensions

The extension mechanism was enhanced to support versioning, allowing applications to specify which version of an extension they required.

FAQ

Why were Generics implemented using type erasure instead of reified types?
Generics used type erasure for backward compatibility with existing code and libraries. This allowed pre-Java 5 collections to work with generic code without requiring recompilation of the entire Java ecosystem.

What's the real benefit of the Executor framework over manual thread creation?
The Executor framework manages thread pooling, reuse, and lifecycle automatically. In practice, this means better performance through thread reuse and less chance of resource exhaustion from creating too many threads.

How do enums in Java 5 differ from just using integer constants?
Java enums are full classes that can have methods, implement interfaces, and provide type safety. The compiler prevents invalid values, unlike integer constants where any int value could be passed.

Is autoboxing/unboxing actually efficient for performance-critical code?
No, autoboxing creates temporary objects that can impact performance in tight loops. For performance-sensitive sections, using primitives directly is still preferable to avoid GC pressure.

What made the new ConcurrentHashMap better than synchronizing a regular HashMap?
ConcurrentHashMap uses fine-grained locking or lock-free techniques for specific segments rather than locking the entire map. This allows concurrent reads and higher throughput when multiple threads access the map simultaneously.

Releases In Branch Java SE 5

VersionRelease date
5.0u8514 Apr 2015
(11 years ago)
5.0u8120 Jan 2015
(11 years ago)
5.0u7514 Oct 2014
(11 years ago)
5.0u7115 Jul 2014
(11 years ago)
5.0u6515 Apr 2014
(12 years ago)
5.0u6114 Jan 2014
(12 years ago)
5.0u5515 Oct 2013
(12 years ago)
5.0u5118 Jun 2013
(12 years ago)
5.0u4516 Apr 2013
(13 years ago)
5.0u4104 Mar 2013
(13 years ago)
5.0u4019 Feb 2013
(13 years ago)
5.0u3901 Feb 2013
(13 years ago)
5.0u3816 Oct 2012
(13 years ago)
5.0u3612 Jun 2012
(13 years ago)
5.0u3526 Apr 2012
(14 years ago)
5.0u3414 Feb 2012
(14 years ago)
5.0u3312 Dec 2011
(14 years ago)
5.0u3218 Oct 2011
(14 years ago)
5.0u3116 Aug 2011
(14 years ago)
5.0u3007 Jun 2011
(14 years ago)
5.0u2921 Apr 2011
(15 years ago)
5.0u2815 Feb 2011
(15 years ago)
5.0u2713 Dec 2010
(15 years ago)
5.0u2612 Oct 2010
(15 years ago)
5.0u2507 Jul 2010
(15 years ago)
5.0u2430 Mar 2010
(16 years ago)
5.0u2313 Jan 2010
(16 years ago)
5.0u2203 Nov 2009
(16 years ago)
5.0u2107 Sep 2009
(16 years ago)
5.0u2004 Aug 2009
(16 years ago)
5.0u1919 May 2009
(16 years ago)
5.0u1824 Mar 2009
(17 years ago)
5.0u1702 Dec 2008
(17 years ago)
5.0u1608 Jul 2008
(17 years ago)
5.0u1504 Mar 2008
(18 years ago)
5.0u1412 Nov 2007
(18 years ago)
5.0u1302 Oct 2007
(18 years ago)
5.0u1220 May 2007
(18 years ago)
5.0u1129 Jan 2007
(19 years ago)
5.0u1029 Nov 2006
(19 years ago)
5.0u919 Oct 2006
(19 years ago)
5.0u808 Aug 2006
(19 years ago)
5.0u724 May 2006
(19 years ago)
5.0u602 Dec 2005
(20 years ago)
5.0u515 Sep 2005
(20 years ago)
5.0u423 Jun 2005
(20 years ago)
5.0u328 Apr 2005
(21 years ago)
5.0u211 Mar 2005
(21 years ago)
5.0u120 Dec 2004
(21 years ago)
5.030 Sep 2004
(21 years ago)