Wildfly is a modular, lightweight Java application server managed by Red Hat that can be deployed for free in your data center or on a third-party cloud host. We’ve covered deploying Wildfly on an Ubuntu Server 20.04 instance and now we’ll take it a step further and see how easy it is to deploy a Java application with the platform.
For this to work, you will need the following:
- A running instance of Wildfly
- A sample Java application to deploy
Before demonstrating the actual deployment, we need to create a deployable Java application. For this, we will turn to the Hello, World!
Install the Java JDK
To create the Java application, we’re going to need a little help from the Java JDK. Since we are demonstrating on Ubuntu, installing the Java JDK is quite simple. Log in to your Ubuntu machine, open a terminal window and run the command:
sudo apt-get install default-jdk -y
The installation will take care of all necessary dependencies. Once complete, you can verify the installation with:
java --version
You should see something like the following in the output:
openjdk 11.0.13 2021-10-19 OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.21.10) OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.21.10, mixed mode , share )
openjdk 11.0.13 2021–ten–19 OpenJDK Duration Environment (to construct 11.0.13+8–Ubuntu–0ubuntu1.21.10) OpenJDK 64–Bit Server VM (to construct 11.0.13+8–Ubuntu–0ubuntu1.21.10, mixed fashion, share) |
Build a Java Application
Next, we’ll create a simple Java application. With Wildfly, you can deploy file types such as EJB-JAR, WAR, EAR, or any standard archive type (like RAR). We will create a WAR archive for our Java deployment.
To do this, create a new directory with the command:
mkdir HELLOWORLD
Navigate to this newly created directory with the command:
cd HELLOWORLD
In this directory, create two other directories with the commands:
mkdir META-INF mkdir WEB-INF
mkdir META–INF mkdir THE WEB–INF |
Next, create the index.jsp file with the command:
nano index.jsp
In this file, paste the following content:
Channel Title = “Hello World”;
%>
If you see this, the sample war file was correctly from >
You are from