java -jar payara-micro.jar --option1 --option2 ...
Deploying Applications From the Command Line
Payara Micro supports deploying applications directly from the command line.
Deploying an Application
As noted in the section Starting an Instance, all Payara Micro actions are run for the Payara Micro JAR, all in one command; it is not possible to start an instance with one command, and deploy an application to it with another.
The general structure of starting, configuring, and deploying an application to an instance is as follows:
Define configuration directory
Payara Micro creates a directory where it creates the equivalent of the Payara Server domain directory in order to run properly.
With the command line parameter
--rootdir one can specify the location of this directory.
It is important to specify this value in production scenarios because the default value is in the temporary directory of the OS which can be cleaned by some processes. If this happens, the application will not behave correctly anymore.
java -jar payara-micro.jar --rootdir <directory-path> --option2 ...
If the <directory-path> doesn’t exist, it is created on the fly.
Deploying an Application Package
To deploy a WAR file to an instance, you need to use the
--deploy option, followed
by the path to the application to deploy. See below for an example of starting a
Payara Micro instance and deploying a WAR file:
java -jar payara-micro.jar --deploy /home/user/example.war
Since 220.127.116.11 and 5.181 the
java -jar payara-micro.jar /home/user/example.war
Deploying an Exploded War
An exploded war can be deployed to a Payara Micro instance just be specifying
the path to the exploded war root directory on the
--deploy command line or
via the API. The exploded war can be redeployed by creating a file .reload
in the root directory of the exploded war and updating its timestamp for example
touch .reload in a LINUX machine.
Deploying Multiple Applications
If you want to deploy multiple applications to an instance with the
option, you must use it once for each application to be deployed; it does not
accept multiple paths.
For example, to deploy 2 applications:
java -jar payara-micro.jar --deploy /home/user/example.war --deploy /home/user/test.war
Alternatively, you can use the
--deploymentDir option. This option specifies
a directory to scan for deployable archives, allowing you to store all of the
applications you wish to be deployed in a directory, and have them be deployed
automatically upon instance startup.
java -jar payara-micro.jar --deploymentDir /home/user/deployments
Deploying Applications from a Maven repository
You can deploy an application directly from a Maven repository using the
--deployFromGAV option. This option accepts a comma separated string denoting
a Maven artefact’s groupId, artifactId, and version attributes.
java -jar payara-micro.jar --deployFromGAV "fish.payara.examples,test,1.0-SNAPSHOT"
This option can be used multiple times, and in conjunction with the standard
By default, Payara Micro will only search for artefacts in the Maven Central
repository. If you wish to search additional repositories, you can add them to
the list of repositories to search with the
java -jar payara-micro.jar --deployFromGAV "fish.payara.examples,test,1.0-SNAPSHOT" --additionalRepository https://maven.java.net/content/repositories/promoted/
To search through multiple additional repositories, you can simply specify the option multiple times:
java -jar payara-micro.jar --deployFromGAV "fish.payara.examples,test,1.0-SNAPSHOT" --additionalRepository https://maven.java.net/content/repositories/promoted/ --additionalRepository https://raw.github.com/payara/Payara_PatchedProjects/master/
Define context root
The context root of an application can be specified using the option
--contextroot or by appending the path to the war-file name given with the
A context root set using the option
--contextroot <context-path> applies to the applciation of the first
--deploy parameter that does not already specify a context root with its
java -jar payara-micro.jar --deploy /home/user/example.war --contextroot hello-world
The root context of the
example.war application is now set to
Alternatively the context root can be included in the argument to the
--deploy option. It follows the path to the war file separated by
--deploy <war-file>:<context-path>(Linux uses
--deploy <war-file>;<context-path>(Windows uses
java -jar payara-micro.jar --deploy /home/user/example.war:hello-world
The above command again results in the effective root context
The two methods can also be used together:
java -jar payara-micro.jar --contextroot bar --deploy /home/user/example.war:foo --deploy /home/user/test.war
example.war is deployed in
test.war is deployed in