Dynamic CDS Archive


Class data sharing is the most important attribute of JVM to uplift the startup time on an application loading. As it permits sharing the class metadata over many non-identical JVM’s it lowers the startup time and memory footprint. Java 10 improved CDS by offering AppCDS, application CDS which grants developers entrance to comprise application classes in a shared archive. In Java 12, CDS Archive is set as the default.

But the procedure of making a CDS was tedious as the maker (developer) has to go through many different trials of their applications to make a class list as an initial step and then dump that class list into an archive. Then this archive can be made use to transfer metadata in the middle of JVMs.

From Java 13 afterward, now Java has dynamic archiving. Now makers can create a shared archive at the time of application way out. So trial procedures are no longer needed.

Create a dynamic shared archive on top of the default system archive by making use of option -XX:ArchiveClassesAtExit by following the below given and passing the archive name.

$java -XX:ArchiveClassesAtExit=sharedApp.jar -cp APITester.jar APITester

The shared archive can be used once generated to run the application by making use of -XX:SharedArchiveFile option

$java -XX:SharedArchiveFile=sharedApp.jar -cp APITester.jar APITester


Examine the below given example:


public class APITester {
   public static void main(String[] args) {
      System.out.println("Welcome to intellinuts.com.");

Assemble and Run the Program

$javac APITester.java

$jar cf APITester.jar APITester.class

$java -XX:ArchiveClassesAtExit=sharedApp.jsa -cp APITester.jar APITester

$java -XX:SharedArchiveFile=sharedApp.jsa -cp APITester.jar APITester


Welcome to intellinuts.com