Java 13

Java 13, released in September 2019, brought several enhancements and new features to the Java platform. Here are some of the key features introduced in Java 13:

Switch Expressions (Standard):

Made switch expressions a standard feature, removing the “preview” status that it had in Java 12. Switch expressions allow switch statements to be used as expressions, enabling more concise and readable code.

  private static String getNumberViaYield2(int number) {
      return switch (number) {
          case 1, 2:
              yield "one or two";
          case 3:
              yield "three";
          case 4, 5, 6:
              int i = 0;
              yield "four or five or six : " + i;
              yield "unknown";

Text Blocks (Preview):

Introduced a preview feature for text blocks, which provide a new way to write multi-line string literals. Text blocks simplify the process of writing and formatting multi-line strings, improving code readability and maintainability.

Dynamic CDS Archives:

Introduced dynamic class data sharing (CDS) archives, which allow the JVM to create CDS archives at runtime. Dynamic CDS archives can improve startup time and reduce memory footprint by preloading classes and resources used by an application.

This command creates a CDS archive file of a .jar.

$ java -XX:ArchiveClassesAtExit=hello.jsa -cp hello.jar Hello

This command runs a .jar with an existing CDS archive.

$  bin/java -XX:SharedArchiveFile=hello.jsa -cp hello.jar Hello

The Class Data Sharing (CDS) improves startup performance by creating a class-data archive once and reusing it so that the JVM needs not to recreate it again.

ZGC Improvements:

Included improvements to the Z Garbage Collector (ZGC), which is designed to handle very large heaps with low-latency garbage collection pauses. These improvements focused on reducing GC pause times and improving overall performance.

FileSystems.newFileSystem() Method:

Added a new FileSystems.newFileSystem() method, which simplifies the process of creating new file systems. This method makes it easier to work with different file system formats and provides more flexibility when working with file-based resources.

Reimplement the Legacy Socket API:

Reimplemented the legacy Socket API ( and related classes) using the NIO-based implementation. This change improves the performance and reliability of socket-based networking operations in Java.


public class JEP353 {

    public static void main(String[] args) {

        try (ServerSocket serverSocket = new ServerSocket(8888)){

            boolean running = true;

                Socket clientSocket = serverSocket.accept();
                //do something with clientSocket

        } catch (IOException e) {


Deprecate the RMIC Tool:

Deprecated the RMIC tool, which is used to generate stub and skeleton classes for Remote Method Invocation (RMI). This tool is no longer needed in modern Java applications, as RMI has been largely replaced by more modern and flexible communication technologies.

These features, along with various performance improvements, bug fixes, and enhancements to existing APIs, made Java 13 a significant release in the ongoing evolution of the Java platform.