
- Java 13 Tutorial
- Java 13 - Home
- Java 13 - Overview
- Java 13 - Environment Setup
- Java 13 Language Changes
- Java 13 - Switch Expressions
- Java 13 - Text Blocks
- Java 13 - Text Block Methods
- Java 13 - Socket API Reimplementation
- Java 13 - Miscellaneous Changes
- Java 13 JVM Changes
- Java 13 - Dynamic CDS Archive
- Java 13 - ZGC Enhancements
- Java Other Versions Tutorials
- Java Tutorial
- Java 8 Tutorial
- Java 9 Tutorial
- Java 10 Tutorial
- Java 11 Tutorial
- Java 12 Tutorial
- Java 13 Useful Resources
- Java 13 - Quick Guide
- Java 13 - Useful Resources
- Java 13 - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java 13 - Dynamic CDS archive
CDS, Class Data Sharing is an important feature of JVM to boost the startup time of an application loading. As it allows to share class metadata across different JVMs, it reduces the startup time and memory footprint. Java 10 enhanced CDS by giving AppCDS, application CDS which gave developers access to include application classes in a shared archive. Java 12 set CDS archive as default.
But the process of creating a CDS was tedious as developers has to go through multiple trials of their applications to create a class list as first step and then dump that class list into an archive. Then this archive can be used to share metadata between JVMs.
From Java 13 onwards, now java has dynamic archiving. Now developers can generate a shared archive at the time of application exit. So trial runs are no more needed.
Following step showcases to create a dynamic shared archive on top of default system archive using option -XX:ArchiveClassesAtExit and passing the archive name.
$java -XX:ArchiveClassesAtExit=sharedApp.jar -cp APITester.jar APITester
Once generated the shared archive can be used to run the application using -XX:SharedArchiveFile option.
$java -XX:SharedArchiveFile=sharedApp.jar -cp APITester.jar APITester
Example
Consider the following example −
APITester.java
public class APITester { public static void main(String[] args) { System.out.println("Welcome to TutorialsPoint."); } }
Compile 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
Output
Welcome to TutorialsPoint.