Codementor Events

Java 8 vs Java 11

Published May 19, 2022
Java 8 vs Java 11

Introduction:

We examine the new features of Java 8 and Java 11 in order to decide whether we should upgrade to the latest LTS version. Are you curious about the new features of Java 8 and Java 11? Then keep reading! We'll go through them and see if we should upgrade.

The new features in Java version 8

Oracle switched away from the Binary Code License with Java version 8. From Java 8 onwards, Oracle released java under two licences:

  1. OpenJDK is licensed under the GNU General Public License version 2 with a classpath exception (GPLv2+CPE).
  2. You can have a commercial license to Oracle technology or services, known as Oracle Technology Network License Agreement (ONTLA).

Java 8 made several significant changes besides this major transformation. Here are some of them:

  1. We can make use of the functional style in Java by employing Lambda expressions. There are several classes and methods in java that accommodate Lambda functionality, such as Method Reference, forEach, and Functional Interfaces.
  2. The way java deals with Date and Time objects was altered. Developments implemented a new date and time API.
  3. An interface can have default methods and method bodies in Java.
  4. Nashorn is a new JavaScript engine to run code directly inside the page.
  5. StringCollector class provides delimiter-based string manipulation.
  6. The Java 8 update brought with it the capability to process and pipeline streams of objects. A stream is a sequence of objects that we may process and pipeline.
  7. A new Collectors class was developed. The Collector class provides reduction operations that can be applied to streams.
  8. The new parallel sort method of the arrays class in Java version 8 is a new way to sort arrays.
  9. The Nashorm JavaScript Engine now has a new command, jjs. Java 8 introduced it.

The list of new features introduced in the Java version 11:

The most significant changes made to Java version 11 are as follows:

  1. As a preview, ZGC or Z Garbage Collector, a new, experimental garbage collector was added.
  2. The new toArray method was added to the Collections interface in Java 11.
  3. The new, more secure cyphers, ChaCha20 and ChaCha20-Poly1305, were introduced instead of the old, less secure ones.
  4. A single Java source code file can now be launched using a new Java launcher.
  5. The var keyword is now a reserved type name for lambda expressions.

Java 11 Removed Features:

Java 11 included a lot of new features and large sections of code being removed. Here are the details:

  1. The Applet Viewer tool was removed from the Java 11 codebase.
  2. The JDK and JRE no longer come together. From Java 11, the only JDK installation is without the JRE. The Applet-related code has been removed from Java version 11. Therefore, the JRE no longer needs to be installed. Oracle's release notes state as follows.
  3. From Java 11, the AWT utility class was removed.
  4. From Java 11, Bundled Fonts were removed.
  5. From Java 11, CORBA and related modules were removed.
  6. The JavaFX modules were split out and removed from the main code.
  7. It is available as a separate application. Like Java FX, it is also part of Java Mission Control.

What are the improvements in Java 11 performance and security?

We looked at the reasons for the language and tool improvements and features included in Java 11. These improvements, in addition to some important security enhancements, are listed below.

  1. In earlier Java versions, nested classes were compiled as separate classes, which required extra compiler processing and adjustments. To support nesting, the compiler had to create synthetic or bridging methods and variables, among other things. The extra processing and adjustments were an overhead. In Java 11, the compiler is improved to handle nesting better. According to the author of the feature, the improved performance is a result of nested classes being compiled as a single class:
  2. New Key exchange algorithms Curve25519 and Curve448 have been developed by developers. Diffie-Helman elliptic curves have been replaced by these to make the key handshake more secure.
  3. As a result of more secure and better cryptographic algorithms, ChaCha20 and Poly1305 being implemented by developers, the older, less secure RC4 cypher algorithms have been supplanted.
  4. The Java Server Sockets Extension package has been altered to support TLS 1.3.
  5. A standardized HTTP client has been implemented.

The new Java version 11 includes depreciation features.

The most significant changes in Java version 11 are as follows:

  1. The UnlockCommericalFeatures and LogCommercialFeatures are no longer supported through the command-line arguments.
  2. The VM.check_commercial_featuresand VM.unlock_commercial_features commands have been deprecated too.
  3. The Nashorn JavaScript engine and associated modules were deprecated in Java 11.
  4. getMIC, initSecContect, unwrap, verifyMIC, and acceptSecContect have been deprecated. These methods were part of the GSS-API security context.
  5. The ThreadPoolExecutor class provides been deprecated too.

There are several reasons why one should upgrade from Java 8 to Java 11.

  1. Applications written in Java 9, 10, and 11 are significantly faster and more secure than previous versions of the language.
  2. ZGC and Epsilon garbage collectors have improved Garbage Collection.
  3. Java upgraded to support TLS 1.3, which is more secure than its predecessors.
  4. Since applets have always been a source of security problems, Java 9 deprecated them. Code related to them was completely removed in Java 11.
  5. The new heap profiler and low overhead flight recorder in Java 11 are examples of new low overhead flight recorders.
  6. It permitted the execution of a single Java source file.
  7. CORBA and Java EE modules have been removed from Java 11 as out-of-date and pose security problems.
  8. The var keyword is also included in the language, making for a simpler development process.

Oracle does not have any more updates for Java 8 and does not provide security updates for it anymore. However, Oracle still supports Java 11. All of these reasons make it desirable to move from Java 8 to 11.

Conclusion:

We looked at all the new features and enhancements in Java 8 vs Java 11 in this java 8 vs java 11 comparison. We also discussed all the functionality and feature removals in Java 11. Despite the fact that Oracle continues to support Java 8, upgrading to Java version 11 is a great idea. The security and performance upgrades are definitely worth the upgrade.

Discover and read more posts from Ankit Dixit
get started
post commentsBe the first to share your opinion
castuloramirez@gmail.com
2 years ago

Java 8 is a LTS and the extended support will be provided till 2030. You can check the official Oracle Java Roadmap.

Show more replies