Packaging the Application

In the previous step you added a custom CDI bean to the app. Now it's time to package and run it as a self-contained JAR file.

Stopping the Running Application

Let's stop the original application so we can package and re-run it as an executable JAR. In the terminal, press CTRL-C to stop the application.

Packaging the Application

Use the package goal to build the application JAR files:

mvn package
This command produces two files:
 
  • getting-started-1.0.0-SNAPSHOT.jar - This JAR contains only the classes and resources of the projects; it’s the regular artifact produced by the Maven build
  • quarkus-app/quarkus-run.jar - The application is also packaged as an executable jar. Be aware that it’s not an über-jar as the dependencies are copied into several subdirectories (and would need to be included in any layered container image).

You can find these two files under the target/ directory:

ls -l target/*.jar target/quarkus-app/*.jar
Note: Quarkus uses the fast-jar packaging by default. The fast-jar packaging format is introduced as an alternative to the default jar packaging format. The main goal of this new format is to bring faster startup times.

Running the Executable JAR

You can run the executable JAR by specifying it to the JVM:
java -jar target/quarkus-app/quarkus-run.jar
You can test that it's running by using the same URL from the previous step:
curl localhost:8080/hello
The Class-Path entry of the MANIFEST.MF from the executable jar explicitly lists the JAR files from the subdirectories under target/quarkus-app. If you want to deploy your application elsewhere, you need to copy the executable jar as well as the folder structure under target/quarkus-app. If you want to create an Uber-jar with everything included, you can use mvn package -DuberJar.

Cleaning Up

Stop the executable JAR by pressing CTRL-C in its terminal.

Next Steps

You've packaged up the application as an executable JAR and learned a bit more about the mechanics of packaging. In the next step, we'll continue our journey and build a native image and then we'll learn about the native executable creation and the packaging in a Linux container.
Daniel Oh
Daniel Oh
Senior Principal Developer Advocate
Daniel Oh is a Senior Principal Developer Advocate at Red Hat. He works to evangelize building cloud-native microservices and serverless functions with cloud-native runtimes to developers. He also continues to contribute to various open-source cloud projects and ecosystems as a Cloud Native Computing Foundation (CNCF) ambassador for accelerating DevOps adoption in enterprises. Daniel also speaks at technical seminars, workshops, and meetups to elaborate on new emerging technologies for enterprise developers, SREs, platform engineers, and DevOps teams.