Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Build even faster Quarkus applications with fast-jar

April 8, 2021
Daniel Oh
Related topics:
ContainersJavaKubernetesQuarkus
Related products:
Red Hat OpenShift

Share:

    Quarkus is already fast, but what if you could make inner loop development with the supersonic, subatomic Java framework even faster? Quarkus 1.5 introduced fast-jar, a new packaging format that supports faster startup times. Starting in Quarkus 1.12, this great feature became the default packaging format for Quarkus applications. This article introduces you to the fast-jar format and how it works.

    Note: The ninth annual global Java developer productivity report found that more developers are implementing business applications with Quarkus. Quarkus's support for live coding with fast startup and response times lets developers focus more on business logic implementations rather than wasting time on jobs such as recompiling and redeploying code and continuously restarting the runtime environment.

    The custom class loader

    To understand fast-jar's secret solution, you need to understand the purpose of the Java class loader and what it processes when a Java application starts up. The Java class loader dynamically loads Java classes into the Java Virtual Machine (JVM) in a Java Runtime Environment (JRE). The Java class loader handles these functions so that the Java runtime doesn't need to know where the files and file systems are. Unfortunately, the class loader loads slower for Java applications with more dependencies. The reason is that the class loader typically takes the O(n) Big O notation on the number of Java application dependencies.

    Quarkus's fast-jar format solves this problem! When you create an application using the fast-jar format, Quarkus uses a custom ClassLoader that already knows the entire classpath when the application is built. The ClassLoader indexes the location of classes and resources that are written at build time, and the location is read at startup time.

    By following the next steps, you can learn for yourself the differences between the legacy JAR format and the new fast-jar format.

    Step 1: Create two Quarkus projects with multiple extensions

    First, use a Maven plugin to scaffold a new project based on Quarkus 1.11.6.Final, which uses the legacy JAR packaging format:

    $ mvn io.quarkus:quarkus-maven-plugin:1.11.6.Final:create \
        -DprojectGroupId=org.acme \
        -DprojectArtifactId=getting-legacyjar-started \
        -DclassName="org.acme.getting.started.GreetingResource" \
        -Dextensions="infinispan-client,rest-client,openshift, resteasy-jackson" \
        -Dpath="/hello"
    

    This command generates a getting-legacyjar-started directory that pulls down infinispan-client, rest-client, openshift, and resteasy-jackson extensions into the new Quarkus project.

    Next, create another project based on Quarkus 1.12.2.Final, with the new fast-jar format:

    $ mvn io.quarkus:quarkus-maven-plugin:1.12.2.Final:create \
        -DprojectGroupId=org.acme \
        -DprojectArtifactId=getting-fastjar-started \
        -DclassName="org.acme.getting.started.GreetingResource" \
        -Dextensions="infinispan-client,rest-client,openshift, resteasy-jackson" \
        -Dpath="/hello"

    This command generates a getting-fastjar-started directory that includes the same extensions, but uses the fast-jar packaging format.

    Step 2: Package the applications to compare formats

    Next, we'll package the applications to compare how differently Quarkus generates classes and resources using the legacy and fast-jar packaging formats. Package the legacy JAR application first, using the following Maven command:

    $ mvn package -f getting-legacyjar-started

    The output should end with BUILD SUCCESS. Then, the runnable JAR will be packaged directly in the target directory where other resources such as lib and classes are also created:

    $ ls -al getting-legacyjar-started/target            
    ...
    drwxr-xr-x   5 danieloh  staff     160 Mar 15 00:31 classes
    drwxr-xr-x  67 danieloh  staff    2144 Mar 15 08:35 lib
    -rw-r--r--   1 danieloh  staff  249897 Mar 15 08:35 getting-legacyjar-started-1.0.0-SNAPSHOT-runner.jar
    ...
    

    Now, package the fast-jar application:

    $ mvn package -f getting-fastjar-started

    Once the build completes, you will find a new self-contained quarkus-app folder in the target directory:

    $ ls -al getting-fastjar-started/target/quarkus-app        
    ...
    
    drwxr-xr-x  3 danieloh  staff   96 Mar 15 14:25 app
    drwxr-xr-x  4 danieloh  staff  128 Mar 15 14:25 lib
    drwxr-xr-x  4 danieloh  staff  128 Mar 15 14:25 quarkus
    -rw-r--r--  1 danieloh  staff  621 Mar 15 14:26 quarkus-run.jar
    ...

    Step 3: Compare the application startup times

    Now, let’s run both applications with the packaged JAR file to see how quickly each one starts. Run the legacy-jar application first:

    $ java -jar getting-legacyjar-started/target/getting-legacyjar-started-1.0.0-SNAPSHOT-runner.jar

    Once the application starts, you will see 1.276 seconds as the boot time, as shown below (the elapsed time could be a bit different depending on your environment):

    INFO  [io.quarkus] (main) getting-legacyjar-started 1.0.0-SNAPSHOT on JVM (powered by Quarkus 1.11.6.Final) started in 1.276s. Listening on: http://0.0.0.0:8080
    

    To do a quick sanity test, you can access the RESTful API using a curl command. Then, you will see the following output:

    $ curl http://localhost:8080/hello
    
    Hello RESTEasy
    

    Stop the development mode by pressing CTRL + C on your keyboard. Then, run the fast-jar application:

    $ java -jar getting-fastjar-started/target/quarkus-app/quarkus-run.jar
    

    Once the application starts, you will see 0.909 seconds as the boot time, as shown below (the elapsed time could be a bit different depending on your environment):

    INFO  [io.quarkus] (main) getting-fastjar-started 1.0.0-SNAPSHOT on JVM (powered by Quarkus 1.12.2.Final) started in 0.909s. Listening on: http://0.0.0.0:8080
    

    The new fast-jar custom ClassLoader delivers a startup time that is 360 milliseconds faster than the legacy JAR application. When you access the endpoint ( /hello), you will have the same output (Hello RESTEasy) as the legacy JAR application.

    The fast-jar format allows the default ClassLoader to keep a minimum number of JARs open for fitting in a container-layering architecture. It also doesn’t need to look up the entire classpath for missing resources in known directories such as META-INF/services.

    Conclusion

    In this article, you learned why applications packaged with fast-jar are faster than those packaged with Quarkus's legacy JAR format. We also did a quick exercise so you could compare the startup times for yourself.

    While we didn't explore this option, you might have almost the same startup time if you run both applications in development mode because development mode doesn’t use a JAR file for packaging. This enhancement is intended for a production environment.

    The fast-jar format is useful for applications with many extensions and dependencies, and the advantages are even greater for applications deployed to a container environment like Red Hat OpenShift. Visit the Quarkus landing page to get started with your next Quarkus journey.

    Last updated: October 7, 2022

    Recent Posts

    • How to enable Ansible Lightspeed intelligent assistant

    • Why some agentic AI developers are moving code from Python to Rust

    • Confidential VMs: The core of confidential containers

    • Benchmarking with GuideLLM in air-gapped OpenShift clusters

    • Run Qwen3-Next on vLLM with Red Hat AI: A step-by-step guide

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue