Skip to main content
AI
  • Get started with AI

    • Red Hat AI

      Accelerate the development and deployment of enterprise AI solutions.

    • AI learning hub

      Explore learning materials and tools, organized by task.

    • AI interactive demos

      Click through scenarios with Red Hat AI, including training LLMs and more.

    • AI/ML learning paths

      Expand your Red Hat OpenShift AI knowledge using these learning resources.

    • AI quickstarts

      Focused AI use cases designed for fast deployment on Red Hat AI platforms.

    • No-cost AI training

      Foundational Red Hat AI training.

  • Featured resources

    • Red Hat OpenShift AI
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

Red Hat AI Factory with NVIDIA

Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.

Learn
  • Self-guided

    • Documentation

      Find answers, get step-by-step guidance, and learn how to use Red Hat products.

    • Learning paths

      Explore curated walkthroughs for common development tasks.

    • Guided learning

      Receive custom learning paths powered by our AI assistant.

    • See all learning
  • Hands-on

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

    • Interactive labs

      Learn by doing in these hands-on, browser-based experiences.

    • Interactive demos

      Click through product features in these guided tours.

  • Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics
  • Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
Build
  • Get started

    • Red Hat build of Podman Desktop

      A downloadable, local development hub to experiment with our products and builds.

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

  • Download products

    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products
  • Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset
  • References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
Community
  • Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions
  • Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github
  • Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

Join the Red Hat Developer program

Download Red Hat products and project builds, access support documentation, learning content, and more.

ConsoleDocsSupport Search
New For you

Recommended

We'll recommend resources you may like as you browse. Try these suggestions for now.

  • Product downloads
  • Cheat sheets
  • Red Hat Developer learning portal
  • Developer blog
  • E-books
  • Developer Sandbox
Log in

Get more with a Red Hat Developer account

  • Product downloads
  • Console access
  • Event registration
  • Training & trials
Explore more account benefitsLog in or register

A subscription may be required for some services.

Contact us

Build even faster Quarkus applications with fast-jar

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

    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

    • A day in the life of an NVIDIA H100 on Red Hat OpenShift 5

    • Migrate BuildConfigs to builds for Red Hat OpenShift with one plug-in install

    • Run Red Hat Enterprise Linux CoreOS on NVIDIA BlueField DPUs

    • Agent harness engineering: Separating model capabilities from enforcement

    • What's new for developers in Red Hat Enterprise Linux 10.3 and 9.9

    Red Hat Developers logo

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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