How to Deploy Java Applications
Last modified: June 5, 2023
Overview
- 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.
How to deploy Java WAR packages
-
Tomcat does not automatically deploy WAR files in the
/home/username/public_html/$filename/
directory because EasyApache disables theunpackWARs
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:
-
If the File Manager interface does not open in it, navigate to the
public_html
directory. -
Click + Folder. The New Folder window will appear.
Note:In cPanel & WHM version 64 and earlier, click New Folder. -
Enter the new folder’s name in the New Folder Name: text box and click Create New Folder.
-
Select your new folder in the center pane of the interface.
-
Click Upload.
-
Click Select File.
Note:In cPanel & WHM version 64 and earlier, click Choose File. -
Browse to the Java WAR package and click Open.
-
Select the file and click Rename.
-
Change the file extension from
.war
to.zip
and click Rename File. -
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 thezip
package via the server’s package manager. -
Select the
.htaccess file
in thepublic_html
directory.Note:If you do not see the
.htaccess
file inside yourpublic_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.
-
-
Click Edit.
-
Click Edit in the Text Editor interface.
-
Enter the following text in the text box:
1 2
SetHandler jakarta-servlet SetEnv JK_WORKER_NAME ajp13
-
Click Save Changes.
-
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
To deploy a Java WAR package via the command line, perform the following steps:
-
Upload your Java WAR package to your
public_html
directory. -
Run the unzip
filename.war
command to extract the package, wherefilename.war
represents the name of your Java WAR package file. -
Open the
.htaccess
file with a text editor and add the following text:1 2
SetHandler jakarta-servlet SetEnv JK_WORKER_NAME ajp13
-
Save your changes.
-
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.