BuycPanel Blog

BuycPanel Blog

Latest news and updates

How to Deploy Java Applications on the Server?

Posted by Allura on 21 01 2019.

Introduction
There are many Java applications addressed in Web Application Archive (WAR) packages that can be easily installed on one’s server.It is to note that installations of Tomcat is not supported by EasyApache 3. In cPanel & WHM version 76, EasyApache 4 supports Tomcat 8.5. One can read our Tomcat  documentation for more detailed information.Also, one’s system administrator must manually install the application, if it does not exist in a WAR package.How to Deploy Java WAR Packages
Important to note that this document is only applied to systems that run EasyApache 3. Tomcat automatically do not deploy WAR files in the /home/username/public_html/$filename/ directory because EasyApache disables the unpackWARs option for some security reasons.A sample WAR file is provided by the Apache Tomcat project that can be used to verify the function of Java WAR packages  on one’s domain. One can view Tomcat’s Sample Application website for more valuable information.Use either of the…

Introduction

There are many Java applications addressed in Web Application Archive (WAR) packages that can be easily installed on one’s server.

It is to note that installations of Tomcat is not supported by EasyApache 3. In cPanel & WHM version 76, EasyApache 4 supports Tomcat 8.5. One can read our Tomcat  documentation for more detailed information.

Also, one’s system administrator must manually install the application, if it does not exist in a WAR package.

How to Deploy Java WAR Packages

Important to note that this document is only applied to systems that run EasyApache 3. Tomcat automatically do not deploy WAR files in the /home/username/public_html/$filename/ directory because EasyApache disables the unpackWARs option for some security reasons.

A sample WAR file is provided by the Apache Tomcat project that can be used to verify the function of Java WAR packages  on one’s domain. One can view Tomcat’s Sample Application website for more valuable information.

Use either of the following methods to deploy Java WAR Packages:

cPanel’s File Manager Interface

One can navigate to cPanel’s File Manager interface (cPanel >> Home >> Files >> File Manager) and perform the steps given below:

Steps:

  1. One can navigate to the public_html directory, in case the File Manager interface does not open in it.
  2. Click on + Folder. Thereafter a New Folder window will appear.

Note that in cPanel & WHM version 64 and earlier, one has to click on New Folder.

  1. After entering the new folder’s name in the New Folder Name: text box, click on Create New Folder.
  2. One can select a new folder in the center pane of the interface.
  3. Click on Upload.
  4. Then click on Select File.

Note that in cPanel & WHM version 64 and earlier, one has to click on Choose File.

  1. One has to browse to the Java WAR package and click on Open.
  2. Select the file and then click on Rename.
  3. One can change the file extension from .war to .zip and after that click on Rename File.
  4. Then select the .zip file and click on Extract.

Note that this function only works with the .zip  format, if Zip exists on one’s server. To install the Zip PHP module, system administrators can run the yum install zip command.

  1. One needs to select the .htaccess file in the public_html directory.
  2. Click on Edit.
  3. Click on Edit in the Text Editor interface.
  4. One has to enter the following text in the text box:
    • SetHandler jakarta-servlet
    • SetEnv JK_WORKER_NAME ajp13
  5. Click on Save Changes.
  6. The Java application needs to be accessed with the http://example.com/exampledirectory/examplejavaapplication URL, where:
    • com will represent your domain name.
    • exampledirectory will represent the Java application’s directory.
    • examplejavaapplication will represent the Java application’s name.

Command Line Interface

Use cPanel’s File Manager interface (cPanel >> Home >> Files >> File Manager) to work on this method.

Steps:

  1. Firstly, upload your Java WAR package to your public_html directory.
  2. Then run the unzip filename.war command in order to extract the package, filename.war representing the name of your Java WAR package file.
  3. Thirdly, open the .htaccess file with the help of a text editor and add:
    • SetHandler jakarta-servlet
    • SetEnv JK_WORKER_NAME ajp13
  4. Then, save all your changes.
  5. Lastly, acccess your Java application with the http://example.com/exampledirectory/examplejavaapplication URL, where:
    • com representing your domain name.
    • exampledirectory representing the Java application’s directory.
    • examplejavaapplet representing the Java application’s name.

Conclusion

All information about ways to deploy Java applications on the server is outlined in this article.