How to Run Payara Micro on Android (No Root Required)

Photo of Jorge Cajas by Jorge Cajas

Have you ever wondered how Micro is Payara Micro?

At first, this was a fun experiment installing a terminal app on my Android phone and playing around with some Linux commands. One thing lead to another and I ended up running a Payara Micro instance on my device! In this article, I'm going to show you exactly how to do that.


For convenience's sake you may want to run this experiment from the comfort of your PC by connecting it via SSH to your device.


Installing Termux and a Linux distribution.

The best terminal app I found is Termux, which is an open source terminal emulator that provides a Linux environment. This means that you can install packages, run common Linux commands, and even configure startup processes when you boot up your phone. One of the most amazing things you can do with it is install community-made images of Linux's distributions like Arch, Debian, Fedora, Kali, Ubuntu, etc.

However, even with Termux, you can't install a JDK yet. After several tries, I installed Fedora 27 in Termux since I realized that is the most lightweight distribution for this requirement. To install it, just type the following commands in Termux (use f27_armor f27_arm64 depending your device):

pkg install wget
bash f27_arm

This operation will take from 10 to 30 minutes depending on your device, so be patient. After the installation is complete start the Fedora environment with the startfedora command:


1 - Payara Micro on Android.png


2 - Payara Micro on Android.png


Installing OpenJDK 8

Now that we are inside of our Fedora 27 environment, we are going to install OpenJDK v8 using the YUM package manager:

yum install java-1.0.8-openjdk

3 - Payara Micro on Android.png

Fedora might want to update some dependencies before installing the JDK, so this might take a while. If you check the Java version with java -version after installing the JDK, you will notice that it will fail; don’t worry about it since it doesn't affect our goal to run an instance of Payara Micro.


Downloading Payara Micro and deploying an application.

Let’s download the Payara Micro JAR file. To do this, just copy the distribution link from the Payara website and use it with the following command:

wget "<PAYARA_MICRO_DOWNLOAD_URL>" -O payara-micro.jar

It's recommended to also download a WAR file like this one to test the server.

This WAR file is a modified project of my JavaEE 7 / Gradle starter project with just an index.html page and 3 sample RESTful web services:


Now that we have a JDK installed, the payara-micro JAR file and a sample WAR artifact, it's deployment time!

java -jar payara-micro.jar --deploy Application.war

4 - Payara Micro on Android.png


9 - Payara Micro on Android.png


This may take several minutes depending on your device, and may throw some exceptions (in some cases), but your application will be deployed nonetheless.

In this case, the server is listening on port 8080 by default, so go to the device web browser and launch the http://localhost:8080 website:


5 - Payara Micro on Android.png


6 - Payara Micro on Android.png


7 - Payara Micro on Android.png


Open the Payara Micro server outside your local Network

In case you want to show your new portable Payara Server to your friends, you can install a service called Ngrok.


To do this, you need to download the ARM version and install it on your Termux terminal. Once installed you can open your server with the following command:

./ngrok http 8080

Which will give you an URL to see your server from the Internet. Isn't it cool?


8 - Payara Micro on Android.png


Final Notes

At this time, the steps to achieve all of the above are a bit convoluted, so maybe in the future the entire process can be simplified to ease running a Payara Micro instance on your smartphone.


Remember that all of this depends on your device specifications, which means that the server can run too slow or become unresponsive. Using my Nexus 5X smartphone, it took up to 5 minutes for the Payara Server's homepage to load, but on a separate tablet with more RAM the page loaded faster.


With an ever increasing performance in mobile processors each year, maybe we can start thinking about creating a distributed-mobile fleet of Payara Micro Servers that talks to several IoT devices using an array of microservices? Can you imagine that?!

Nearby devices sharing real-time data powered by Java EE and/or MicroProfile? Future possibilities are unlimited...!


 Payara Server & Payara Micro  Download Here