Java 11 New Features At A Glance

Java Programming Tutorials

The Java 11 New Features at a Glance from Coding compiler – After Java 10, the first “normal” release after the new release cycle, was released on time, the first version with long-term support is now available with Java 11.

Due to the new semi-annual release cycle since Java 9 (September 2017), as an interested Java developer you can not look as fast as the next major version of the most widely used programming language has already been published.

The New Java 11 Features

Java 11 has just finished the first Long Term Support (LTS) release since Java 8 and we want to take a look at the new features of the language and the changes in the API. As the normal support (free updates) for the Oracle JDK 8 will already expire in January 2019, for many now also the question arises, whether one should switch from Java 8 to 11 in the near future. 

It is only now that Java 8 has arrived in the mainstream. The just four-year-old features around lambdas and streams are now used by a large number of developers. And now we should already deal with the next versions and change to the current LTS version?

Related Java 11 Article: 17 New Features In Java 11 | JDK 11 Features

That’s what Oracle seems to intend. However, according to various studies, many still shy away from switching to the versions according to Java 8. Especially the major changes that the module system of Java 9 (Project Jigsaw) brought with it, cause headaches and the necessary migration is postponed in many places. Even Josh Bloch, creator of the Java Collection Framework, currently advises against using the module system:

It is too early to say whether it wants to achieve widespread use outside of the JDK itself. In the meantime, it seems best to avoid them unless you have a compelling need.

Josh Bloch in “Effective Java: Third Edition”

Of course, Java 9, 10 and 11 can be used without the module system or with minimal invasive intervention in existing applications. Nevertheless, the respect is great, after all, most manufacturers of libraries and frameworks so far only very hesitant to the innovations on.

The last few weeks and months have also been heavily influenced by debates about Oracle’s new support and licensing policies and the question of whether Java or the JDK remain free at all. To get straight to the point, Java and the JDK will continue to be free to use in the future and will also receive free updates and security patches for a sufficient amount of time. 

Java 11: What’s new?

The innovations of Java 11 are relatively clear. This is not surprising given the short period since the release of the previous version. The following Java Enhancement Proposals (JEPs) have been implemented:

  • 181: Nest-Based Access Control
  • 309: Dynamic Class File Constants
  • 315: Improve Aarch64 Intrinsics
  • 318: Epsilon: A No-Op Garbage Collector
  • 320: Remove the Java EE and CORBA Modules
  • 321: HTTP Client (default)
  • 323: Local Variable Syntax for Lambda Parameters
  • 324: Key Agreement with Curve25519 and Curve448
  • 327: Unicode 10
  • 328: Flight recorder
  • 329: ChaCha20 and Poly1305 Cryptographic Algorithms
  • 330: Launch Single-File Source Code Programs
  • 331: Low overhead heap profiling
  • 332: Transport Layer Security (TLS) 1.3
  • 333: ZGC: A Scalable Low-Latency Garbage Collector
  • 335: Deprecate the Rhino JavaScript Engine
  • 336: Deprecate the Pack200 Tools and API

From a developer’s perspective, only a few points are really relevant, namely those highlighted in the list above.

For example, JEP 323 implemented an extension of the Local Variable Type Inference introduced in Java 10. Type inference is the deduction of data types from the rest of the source code and typing rules. This saves paperwork and does not inflate the source code unnecessarily, which in turn increases readability.

Since Java 10, local variables can be vardeclared with the keyword as follows:

Works since Java 10// 

var zahl = 5; // int

var string = "Hello World"; // String

var object = BigDecimal.ONE; // BigDecimal

New in Java 11 is that you can now vardeclare lambda parameters as well . At first glance, this may not seem particularly sensible, since you can omit the type of lambda parameters anyway and have them determined via the type inference. The extension is useful for the use of Type Annotations like @Nonnulland @Nullable.

// Inference of lambda parameters

Consumer<String> printer = (var s) -> System.out.println(s); 

// statt s -> System.out.println(s);

// but no mix of "var" and declared types possible

// BiConsumer<String, String> printer = (var s1, String s2) -> System.out.println(s1 + " " + s2);

// Useful for Type Annotations

BiConsumer<String, String> printer = (@Nonnull var s1, @Nullable var s2) -> System.out.println(s1 + (s2 == null ? "" : " " + s2));
The next interesting innovation is the standardization of the still experimental new HTTP Client API, which was introduced with JDK 9 and updated in JDK 10 (JEP 110). In addition to HTTP / 1.1, HTTP / 2, WebSockets, HTTP / 2 Server Push, synchronous and asynchronous calls, and Reactive Streams are now also supported. Garnished with a legible Fluent interface, the use of other HTTP clients (such as Apache) will probably be obsolete in the future.
HttpClient client = HttpClient.newHttpClient();

HttpRequest request = HttpRequest.newBuilder()



client.sendAsync(request, asString())




The JEP 330 (Launch Single-File Source-Code Program) can now start classes that have not yet been compiled. Single-file programs are now commonplace in writing small utilities, and especially the domain of scripting languages. Now you can save yourself in Java, the unnecessary work and at the same time reduces the entry threshold for Java newbies. Until Java 10 Java programs could be started in three ways:

  • as a *.classfile
  • as a main class in a *.jarfile
  • as a main class in a module

New from Java 11 is now starting a class that is declared in a source code file:

# java
// instead of
# javac
# java -cp . hello.World

On unixoid operating systems Java files can even be executed as Shebang files directly:

#!/path/to/java --source version
# ./

Other notable changes include support for the Unicode 10 standard and integration of the Profiler Flight Recorder into the OpenJDK (previously only available with the Oracle JDK). The goal of the Flight Recorder is to record application data as efficiently as possible to analyze the Java application and JVM in case of problems.

API changes

Of course there were countless small changes to the Java class library. Especially a lot has happened with strings:

|  Welcome to JShell -- Version 11
|  For an introduction type: /help intro
// Unicode zu String
jshell> Character.toString(100)
$1 ==> "d"
jshell> Character.toString(66)
$2 ==> "B"
// Multiply characters by factor
jshell> "-".repeat(20)
$3 ==> "--------------------"
// Does a text contain no characters (at most blanks)?
jshell> String msg = "hello"
msg ==> "hello"
jshell> msg.isBlank()
$5 ==> false
jshell> String msg = "  "
msg ==> "  "
jshell> msg.isBlank()
$7 ==> true
// Truncate leading or trailing spaces
jshell> " hello world ".strip()
$8 ==> "hello world"
jshell> "hello world    ".strip()
$9 ==> "hello world"
jshell> "hello world    ".stripTrailing()
$10 ==> "hello world"
jshell> "        hello world    ".stripLeading()
$11 ==> "hello world    "
jshell> "    ".strip()
$12 ==> ""
// Process texts line by line
jshell> String content =  "this is a multiline content\nMostly obtained from some file\rwhich we will break into lines\r\nusing the new api"
content ==> "this is a multiline content\nMostly obtained fro ... ines\r\nusing the new api"
jshell> content.lines().forEach(System.out::println)
this is a multiline content
Mostly obtained from some file
which we will break into lines
using the new api

Java 11: What was removed?

Announcements in the form of deprecations in versions 9 and 10 have now become reality in Java 11. In the JEP 320 various Java Enterprise Packages were removed from the Java SE, these include JAX-WS (XML-based SOAP web services including the tools wsgen and wsimport ), JAXB (Java XML Binding including the tools schema and xjc ), JAF (Java Beans Activation Framework), Common Annotations ( @PostConstruct@Resource, …), CORBA and JTA (Java Transaction API).

Also new is that the Oracle JDK will no longer contain JavaFX (with the OpenJDK it has never been delivered). Instead, JavaFX is offered via OpenJFX as a separate download and can be used like any other library in any Java application. In addition to JavaFX, support for applets and Java Web Start will also be discontinued. However, the open source community is already planning follow-up projects . If you still want to use Java Web Start at the moment, you first have to stay with the Oracle JDK 8 and either live without security updates or spend money on commercial support from 2019.

Newly marked as deprecated in Java 11 was the JavaScript engine rhino . It is expected that it will disappear in future versions of Java. However, Rhino has never really been able to assert itself as a server-side JavaScript implementation over Node.js. And with the GraalVM, Oracle is now taking alternative ways to run other programming languages ​​natively on the JVM.

By the way, starting with Java 11, the Java Runtime Environment (JRE) will only exist in the server version and not for desktops anymore. However, for desktop applications with the module system and the jlinktool, you can now easily create resized runtime environments.

Java 11 Support and licensing policy of Oracle

With Java 11, Oracle is introducing a new licensing and support strategy. Free updates for the latest Long Term Support (LTS) version 8 will not be available from January 2019. In addition, starting with Java 11, the Oracle JDK can only be used free of charge in development; in production, a support contract with Oracle must be concluded against corresponding fees.

However, the Oracle JDK is now binary compatible with the OpenJDK, which is released under the GNU General Public License v2 (with the classpath exception – GPLv2 + CPE). In order to be able to use the JDK in production for free, you can use the OpenJDK as of Java 11. However, Oracle always only offers updates for the current OpenJDK version, ie with the next semi-annual major release, you have to potentially update the application to the next version.

However, alternative vendors such as Azul and IBM have already announced in the AdoptOpenJDK project to provide the LTS versions (eg Java 11) for up to four years with free updates. So for us users of the Java platform, there are enough options between commercial solutions from Oracle (and also Azul Zulu, IBM OpenJ9, etc.) and still free solutions with the OpenJDK as well as the extended support of the AdoptOpenJDK project . But of course, some courage is needed to turn your back on Oracle and give alternative Java platforms a chance.

For a long time, it has become apparent at Oracle that Java is no longer seen merely as a platform that has been acquired and, in particular, developed further in its own interest. Rather, Java is more and more marketed as an Oracle product, where unprofitable parts may be discontinued. But this will also boost competition in the market, which is basically positive. Let’s be curious how the market will present itself in a year.


The big surprises have certainly failed. Rather, Java 11 finalizes begun work from the previous two versions, so it is well prepared as LTS release for the next 3 years. For this purpose, some old braids were cut off and removed, for example, JavaFX and various Java EE packages from the JDK. Java 12 is already in the starting blocks and is expected to be released in March 2019. Currently only two innovations are planned, but more will follow in the next few weeks:

  • JEP 325: Switch Expressions
  • JEP 326: Raw String Literals

Both language features come from so-called incubator projects ( Amber , Valhalla , Loom ), in which smaller developer productivity-enhancing speech and VM features are hatched and then accepted as Java Enhancement Proposals (JEPs).

Thus, in the future, switch statements can also be used as an expression that directly returns the result of the corresponding case branch.

Leave a Reply

Your email address will not be published. Required fields are marked *