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 buildquarkus-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 pressingCTRL-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.