Creating Uber JAR with Payara Micro 5

Photo of Fabio Turizo by Fabio Turizo

Payara Micro allows you to run web applications in a self-contained and easy way. Since the release of the Payara Server in May 2016, there is a simple way to generate an "Uber" JAR that bundles the contents of a WAR file and the classes and resources that compose Payara Micro!

Note that this "Uber" Jar is not the best way to run your application in a Docker container as it requires an update of the entire binary for each small code change you make in the application. A better solution is just to start a Payara Micro Instance and point to the application that needs to be installed. More information can be found on our Payara Micro Docker Image documentation.

(last updated 06/04/2021)


First, generate a web application using traditional means (like Maven for example). Then, deploy this application with Payara Micro with the --outputUberJar option enabled to generate the resulting JAR file:

java -jar payara-micro-5.2021.1.jar --deploy test-app.war --outputUberJar test-app.jar

You will get an output like the following:

Apr 06, 2021 9:09:47 AM fish.payara.micro.impl.UberJarCreator buildUberJar
INFO: Building Uber Jar... test-app.jar
Apr 06, 2021 9:09:48 AM fish.payara.micro.impl.UberJarCreator buildUberJar
INFO: Built Uber Jar basic-servlet.jar in 450 (ms)

And finally, with this Uber jar created, you can just run the application using a simple Java command:

java -jar test-app.jar

With this, the Payara Micro instance will startup and deploy the original web application!  

Now, what happens if you want to change the HTTP port this application uses (8080 by default)? Or disable the clustering capabilities? You can pass all compatible Payara Micro configuration options for the Uber jar generation, and when the application is run these options will be used to configure the server instance:

java -jar payara-micro-5.2021.1.jar --deploy test-app.war --outputUberJar test-app.jar --port 9898 --noCluster


java -jar payara-micro-5.2021.1.jar --deploy test-app-1.war --deploy test-app-2.war --outputUberJar test-app.jar


[2021-04-06T09:56:53.923+0000] [] [INFO] [] [PayaraMicro] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1617693676410] [levelValue: 800] Deployed 2 archive(s)