Chapter 6. Packaging Quarkus Applications
In this chapter, you will learn about packaging a Quarkus service into a JVM or a native format so that it can be distributed and deployed. Today, when containers are becoming the standard way to distribute applications, you need to know how to containerize them.
We’ll cover the following topics:
-
How to package a Quarkus application for running in the JVM
-
How to package a Quarkus application in a native executable
-
How to containerize a Quarkus application
6.1 Running in Command Mode
Problem
You want to create a CLI application.
Solution
With Quarkus, you can also write applications that run and then optionally exit.
To enable command mode in Quarkus, you need to create a class that implements the io.quarkus.runtime.QuarkusApplication interface:
packageorg.acme.quickstart;importio.quarkus.runtime.Quarkus;importio.quarkus.runtime.QuarkusApplication;publicclassGreetingMainimplementsQuarkusApplication{@Overridepublicintrun(String...args)throwsException{System.out.println("Hello World");Quarkus.waitForExit();return0;}}
Interface to set Quarkus in command mode
The method executed when the
main
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access