What is New in Java 11
Java 11 is a Long-Term Support (LTS) release that focuses on cleaning up the platform by removing outdated modules and tools while adding modern features. It standardizes the HTTP Client, introduces new garbage collectors, enhances security with TLS 1.3 and better cryptography, and improves the language with local-variable syntax for lambdas and easier single-file program execution.
Language Improvements
Local-Variable Syntax for Lambda Parameters
You can now use var to declare lambda parameters, allowing annotations like @NonNull for better type inference and readability.
(var x, var y) -> x + y
(@NonNull var s) -> s.length()
Launch Single-File Source-Code Programs
Run a Java program directly from a single source file without compiling first. This is great for quick scripts and learning.
java HelloWorld.java
Nest-Based Access Control
Classes in the same nest (like inner classes) can access each other's private members directly, without needing synthetic methods.
HTTP Client (Standard)
The modern HTTP Client, previously incubated, is now a standard feature in java.net.http. It supports HTTP/1.1 and HTTP/2, WebSocket, and asynchronous requests for cleaner networking code.
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://example.com"))
.build();
client.sendAsync(request, BodyHandlers.ofString())
.thenApply(HttpResponse::body)
.thenAccept(System.out::println);
Security Enhancements
TLS 1.3 Support
Full implementation of the latest TLS protocol for stronger encryption, better performance, and forward secrecy.
ChaCha20 and Poly1305 Algorithms
New cryptographic ciphers as secure alternatives to older ones like RC4.
Curve25519 and Curve448 Key Agreement
Modern elliptic curve cryptography for key exchange.
Flight Recorder
Low-overhead profiling tool now fully available for monitoring and diagnostics.
Garbage Collection Updates
ZGC (Experimental)
A scalable low-latency garbage collector with pause times under 10ms, even for large heaps.
Epsilon GC (Experimental)
A no-op collector that allocates memory but never reclaims it, useful for short-lived apps or testing.
Other Notable Additions
- Support for Unicode 10 with thousands of new characters and emoji.
- Low-overhead heap profiling for better memory analysis.
- Dynamic class-file constants for more efficient bytecode.
- New default method in Collection.toArray for type-safe arrays.
Major Removals
Java 11 removes several legacy components to streamline the platform:
| Removed Feature | Description |
|---|---|
| Java EE and CORBA Modules | Modules like JAXB, JAX-WS, and CORBA are no longer included; use external dependencies instead. |
| JavaFX | Moved to a separate project (OpenJFX). |
| Java Mission Control | Now available as a separate download. |
| Applets and Web Start | Deployment technologies fully removed. |
| Related Tools | Tools like wsgen, wsimport, and idlj are gone. |
Deprecations
- Nashorn JavaScript Engine and jjs tool are deprecated.
- Pack200 tools and API are marked for future removal.
- Security Manager is deprecated in favor of modern alternatives.
Why Upgrade to Java 11
As an LTS release, Java 11 provides long-term support and stability for production use. It modernizes the platform by removing old baggage, adds secure and efficient networking, and introduces tools for better performance. Developers can write simpler code and build more scalable applications while preparing for future Java versions.