How to Deploy a Java App with the Wildfly Application Server – InApps is an article under the topic Software Development Many of you are most interested in today !! Today, let’s InApps.net learn How to Deploy a Java App with the Wildfly Application Server – InApps in today’s post !

Read more about How to Deploy a Java App with the Wildfly Application Server – InApps at Wikipedia



You can find content about How to Deploy a Java App with the Wildfly Application Server – InApps from the Wikipedia website

Wildfly is a modular, lightweight Java application server that is maintained by Red Hat and is free to deploy to your data center or third-party cloud host. We’ve covered the deployment of Wildfly on a Ubuntu Server 20.04 instance and now we’re going to take that a step farther and see how easy it is to deploy a Java application with the platform.

To make this work, you’ll need the following:

  • A running instance of Wildfly
  • A sample Java application to deploy

Before we demonstrate the actual deployment, we have to create a deployable Java application. For that, we’ll turn to the tried and true Hello, World!

Install the Java JDK

To create the Java application, we’re going to need a bit of help from the Java JDK. Since we’re demonstrating on Ubuntu, the installation of the Java JDK is quite simple. Log into your Ubuntu machine, open a terminal window, and issue the command:

sudo apt-get install default-jdk -y

The installation will take care of all the necessary dependencies. When it completes, you can verify the installation with:

java --version

You should see something like the following in the output:

Build a Java application

Next, we’re going to build a simple Java application. With Wildfly, you can deploy file types such as EJB-JAR, WAR, EAR, or any kind of standard archive (such as RAR). We’ll be creating a WAR archive for our Java deployment.

To being, create a new directory with the command:

mkdir HELLOWORLD

Change into that newly created directory with the command:

cd HELLOWORLD

In that directory create two more directories with the commands:

Next, create the index.jsp file with the command:

nano index.jsp

In that file, paste the following contents:

<!doctype html>
<html>
        <head>
                <title>JSP Test</title>
                <%!
                        String title = “Hello World”;
                %>
        </head>
        <body>
                <h2><%= title %></h2>
                <p>
                        If you see this, the example war-file was correctly de>
                </p>
                <p>
                        <%= new java.util.Date() %>
                </p>
                <p>
                        You are from <%= request.getRemoteAddr() %>
                </p>
                <div id=”conrgrats”></div>

                <style>
                        #conrgrats {
                                width: 440px;
                                height: 302px;
                                background: no-repeat left center       url(‘d>
                        }
                </style>
        </body>
</html>

Save and close the file.

Next, create the MANIFEST.MF file with the command:

nano META-INF/MANIFEST.MF

In that file, paste the following:

Where NAME is your name.

Save and close that file.

Create the web.xml file with the command:

nano WEB-INF/web.xml

Paste the following contents into that file:

Save and close the file. If we issue the tree command, we’ll see the structure of your Java application looks like this:

├── index.jsp
├── META-INF
│   └── MANIFEST.MF
└── WEB-INF
└── web.xml

With everything in place, we can now create a .war file with the command:

jar -cvf helloworld.war *

The options are:

  • c – Create a new Jar archive.
  • v – Generates verbose output.
  • f – Sets the file name to what follows the option (in our case helloworld.war.

When the command completes, you’ll find the helloworld.war file in the directory.

Deploy the New Java Application

It’s now time to deploy our Hello, World! Java application. Log into your instance of Wildfly and, from the main page, click Start (under Deployments — Figure 1).

Figure 1

Accessing the Deployment tool in the Wildfly web-based interface.

On the resulting page, drag the helloworld.war file into the Deployment pane on the left side (Figure 2).

Figure 2

The Deployment window allows for easy drag-and-drop addition of supported files.

Once the file has been uploaded, it’ll be listed in the Deployment pane (Figure 3).

Figure 3

Our helloworld.war file has been successfully deployed to Wildfly.

Click on the helloworld.war entry to display the attributes of the application (Figure 4).

Figure 4

The details of our helloworld.war application as seen by Wildfly.

Within the details, you should see a link for the root of the application, listed as /helloworld. If you click on that link, it should take you to the running application (Figure 5).

Figure 5

Running the Hello, World! application gives us a friendly reminder that it’s running as expected.

You can deploy as many applications as you need and they can then be accessed from the server by way of a web browser and an address like http://SERVER:8080/APP/ (where SERVER is either the IP address or DOMAIN of the hosting server and APP is the name of the app. In our case, the app URL would be:

Read More:   Why COVID-19 Contact Tracing Requires a Distributed Database – InApps Technology 2022

http://192.168.1.5:8080/helloworld/

Anyone on your LAN should be able to access that application.

If you want to disable your deployed application, click the drop-down next to View and select Disable (Figure 6).

Figure 6

Disabling our Hello, World application from within Wildfly.

 

You can also undeploy an app by selecting Undeply from the same drop-down.

Conclusion

Wildfly is a very powerful and simple-to-use Java application server. If you’re looking to deploy a Java-based application to either your LAN, WAN, or from a third-party cloud host, this is a great place to start.

InApps is a wholly owned subsidiary of Insight Partners, an investor in the following companies mentioned in this article: Bit.



Source: InApps.net

Rate this post
As a Senior Tech Enthusiast, I bring a decade of experience to the realm of tech writing, blending deep industry knowledge with a passion for storytelling. With expertise in software development to emerging tech trends like AI and IoT—my articles not only inform but also inspire. My journey in tech writing has been marked by a commitment to accuracy, clarity, and engaging storytelling, making me a trusted voice in the tech community.

Let’s create the next big thing together!

Coming together is a beginning. Keeping together is progress. Working together is success.

Let’s talk

Get a custom Proposal

Please fill in your information and your need to get a suitable solution.

    You need to enter your email to download

      Success. Downloading...