ea3

How to Deploy Java Applications


Last modified: June 5, 2023

Overview

Important:
  • This document only applies to systems that run EasyApache 3.
  • EasyApache 3 does not support new installations of Tomcat.
  • As of cPanel & WHM version 76, EasyApache 4 supports Tomcat 8.5. To deploy Java applications with Tomcat 8.5, read our Introduction to Tomcat documentation.

Many Java applications ship in Web Application Archive (WAR) packages that you can easily install on your server.

Note:
If your application does not exist in a WAR package, your system administrator must manually install it.

How to deploy Java WAR packages

Important:
  • Tomcat does not automatically deploy WAR files in the /home/username/public_html/$filename/ directory because EasyApache disables the unpackWARs option for security reasons.

  • The Apache Tomcat project provides a sample WAR file that you can use to verify that Java WAR packages function on your domain. For more information, view Tomcat’s Sample Application website.

To deploy a Java WAR package, use either of the following methods:

File Manager Interface

To deploy a Java WAR package via the cPanel interface, navigate to cPanel’s File Manager interface (cPanel » Home » Files » File Manager) and perform the following steps:

  1. If the File Manager interface does not open in it, navigate to the public_html directory.

  2. Click + Folder. The New Folder window will appear.

    Note:
    In cPanel & WHM version 64 and earlier, click New Folder.
  3. Enter the new folder’s name in the New Folder Name: text box and click Create New Folder.

  4. Select your new folder in the center pane of the interface.

  5. Click Upload.

  6. Click Select File.

    Note:
    In cPanel & WHM version 64 and earlier, click Choose File.
  7. Browse to the Java WAR package and click Open.

  8. Select the file and click Rename.

  9. Change the file extension from .war to .zip and click Rename File.

  10. Select the .zip file and click Extract.

    Note:
    This function only works with the .zip format if Zip exists on your server. System administrators can install the zip package via the server’s package manager.
  11. Select the .htaccess file in the public_html directory.

    Note:

    If you do not see the .htaccess file inside your public_html directory, perform the appropriate steps for your version of cPanel & WHM:

    • For cPanel & WHM version 64 and earlier, exit and then reenter cPanel’s File Manager interface (cPanel » Home » Files » File Manager). When you reenter the interface, select the Show Hidden Files (dotfiles) checkbox.

    • For cPanel & WHM version 66 and later, click Settings, select the Show Hidden Files (dotfiles) checkbox, and then click Save.

  12. Click Edit.

  13. Click Edit in the Text Editor interface.

  14. Enter the following text in the text box:

    1
    2
    
    SetHandler jakarta-servlet
    SetEnv JK_WORKER_NAME ajp13

  15. Click Save Changes.

  16. Access your Java application with the http://example.com/exampledirectory/examplejavaapplication URL, where:

    • example.com represents your domain name.

    • exampledirectory represents the Java application’s directory.

    • examplejavaapplication represents the Java application’s name.

Command Line Interface

Important:
If you cannot access your server via SSH, you must use cPanel’s File Manager interface (cPanel » Home » Files » File Manager).

To deploy a Java WAR package via the command line, perform the following steps:

  1. Upload your Java WAR package to your public_html directory.

  2. Run the unzip filename.war command to extract the package, where filename.war represents the name of your Java WAR package file.

  3. Open the .htaccess file with a text editor and add the following text:

    1
    2
    
    SetHandler jakarta-servlet
    SetEnv JK_WORKER_NAME ajp13

  4. Save your changes.

  5. Access your Java application with the http://example.com/exampledirectory/examplejavaapplication URL.

    Note:
    • example.com represents your domain name.

    • exampledirectory represents the Java application’s directory.

    • examplejavaapplet represents the Java application’s name.

Your Java applications are ready to use.

Additional Documentation