Deploying Applications From the Command Line
Payara Micro Community supports deploying applications directly from the command line.
As noted in the section Starting an Instance, all Payara Micro actions are run for the Payara Micro JAR, all in one command.
The general structure of starting, configuring, and deploying an application to an instance is as follows:
java -jar payara-micro.jar --option1 --option2 ...
When persistent configuration directory is reused across restarts (i. e. not running in a container), it is recommended not to specify deployment each time Payara Micro is invoked from that directory. Doing so will cause the application to be deployed twice — once at startup and second time when deployment section of the command line is processed.
The best approach if your application uses persistent filesystem is to use warmup run for deployment:
# perform deployments and configuration java -jar payara-micro.jar --rootdir micro-root --warmup application.war # all further invocations do not specify deployment java -jar payara-micro.jar --rootdir micro-root
Alternatively a launcher can be generated for configured root directory as well:
# perform deployments and configuration java -jar payara-micro.jar --rootdir micro-root --warmup application.war java -jar payara-micro.jar --rootdir micro-root --outputlauncher # all further invocations use parameterless launcher java -jar micro-root/launch-micro.jar
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 Community instance and deploying a WAR file:
java -jar payara-micro.jar --deploy /home/user/example.war
Since 126.96.36.199 and 5.181 the
java -jar payara-micro.jar /home/user/example.war
An exploded war can be deployed to a Payara Micro Community 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.
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
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/
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