Java 11 in a Nutshell

Hakan Eröztekin
Oct 11, 2020 · 5 min read
Image for post
Image for post
Photo by Blake Wisz on Unsplash

Java is one of the world’s most widely used and in-demand programming languages. Since it’s arrival in 1995, Java kept improving over time. With its frequent release cycle in the recent years, it requires a bit more effort to keep up with the new releases.

We will start with a small Q&A section to clear out the questions and then discuss the Java 11 changes with “in a nutshell” approach. In approximately 15 minutes, you will get familiar with what’s changed with Java 11. There is also a slide version of the article as well.

Let’s begin.

First of all, why are there so many releases?

Image for post
Image for post

Oracle used to release a new version every 2 to 3 years. However, it took great effort for companies to adopt too many changes at once.

Oracle then adopted continuous release approach and announced 6 months release period. Since Java 9, Oracle releases a new Java version with relatively minor changes every 6 months.

What is LTS?

So which version should I upgrade to?

Oracle (and others) “highly recommend that you uninstall older versions of Java”, because of serious risks due to unresolved security issues. Since Java 9 (and 10) is no longer supported, Oracle advises its users to “immediately transition” to Java 11 (Java 15 is also a non-LTS option) - wiki

Java 11 is the latest LTS, until the release of Java 17 in September 2021. It’s backwards compatible with Java 8 (we’ll talk about the details). Also it brings noteworthy features and improvements in addition to Java 8.

Is Java 11 free to use?

The confusion comes from licensing. There are two types of licenses. OpenJDK is free to use, while Oracle JDK provides long-term support for a price. The binaries of these are almost identical so you can use OpenJDK with ease. If you’re interested here is the complete list of differences for Java 11.

Let’s continue with what Java 11 brings to the table.

Overview of New Features

  1. Launching Single-File Java Program
  2. New Library Methods for Strings, Collections and Files
  3. Performance and Security Improvements
  4. Other Enhancements
  5. Removed and Deprecated Features

1. HTTP API

HTTP API is a Java library to execute HTTP requests.

motivation

features

  • Supports common HTTP methods like GET, POST, PUT, DELETE
  • Can handle synchronous and asynchronous communication

how to use

  1. Create and initialize HttpRequest
  2. Pass HttpRequest to HttpClient, execute the request and retrieve HttpResponse
  3. Handle HttpResponsefor your purposes

example

Http Api Example

2. Launching Single-File Java Program

Java 11 supports execution of single file Java program with a single command.

details

  • It has to be a single-file program only (with one or more classes).
  • We can’t use external dependencies.

how to use

3. New Library Methods for Strings, Collections and Files

Java 11 added some useful methods for the mentioned libraries for convenience.

strings api

  • Check empty/whitespace: Check if string is empty or whitespace only. String.isBlank(). It’ll throw NullPointerExceptionif the string is blank.
  • Remove whitespaces: Remove leading String.stripLeading(), trailing String.stripTrailing() or both whitespaces String.strip()
  • Process multiline string: Convert multiline /n string to stream of lines with String.lines()

collections api

optional and predicate.

files api

4. Performance and Security Improvements

performance Improvements

  • ZGC: An experimental but scalable and low-latency GC. It guarantees maximum pause time of 10 ms. ZGC is great for applications memory consuming applications that handle a lot of data.
  • Epsilon: An experimental but low-overhead GC. It’s a good fit for short living applications (executing a single command then closing).

security Improvements

5. Other Enhancements

  • Adoption of Unicode 10: Java 11 uses Unicode 10, an upgrade from Java 10 with Unicode 8. That includes 16,018 new characters and 10 new scripts.
  • Nested access control: Inner class can access all private variables and methods of Outer class (eg. Outer.name).
  • Java Flight Recorder: JFR is a profiling and diagnostics (resource usage etc.) tool. We can also use Java Mission Control to visualize data provided by JFR.

6. Removed and Deprecated Features

removed features

Also, Applets and Java Web Start are completely removed without a replacement. If you’re looking for Java desktop application development, check out JavaFX.

deprecated features

conclusion

If you’re into learning all the aspects of Java in a nutshell, feel free to check out my Java in a Nutshell article.

Happy coding!

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data…

Sign up for Analytics Vidhya News Bytes

By Analytics Vidhya

Latest news from Analytics Vidhya on our Hackathons and some of our best articles! Take a look

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Hakan Eröztekin

Written by

Software Development Engineer @ trendyol, hakaneroztekin.com

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

Hakan Eröztekin

Written by

Software Development Engineer @ trendyol, hakaneroztekin.com

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store