Open In App

How to Start Tomcat Server ?

Last Updated : 16 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Tomcat is a free and open-source web server. It was developed at Sun Microsystems (an American technology company, currently acquired by Oracle). Tomcat is the implementation of Java EE (Java Enterprise Edition) in the newer version of Jakarta Package (Jakarta EE). It supports Jakarta Servlet, Jakarta Server Page, Jakarta Expression Languages, Jakarta WebSockets, etc. It provides a “JAVA HTTP” web server.

History About Tomact

  • Tomcat is a lightweight Java application server initially developed by Sun Microsystems in 1998. It was handled by the Apache Software Foundation in 1999.
  • The latest version of Apache Tomcat is the Tomcat 9 version.

How to Install Apache Tomcat and Setup the Environment

Pre-requisite:

Steps To Start Tomcat Server In Windows

Step 1: First, you have to download the Windows Service Installer from their official website using the Windows Tomcat Binary Distribution.

binary_distribution_apache_tomcat

Step 2: In the Screen we can see

Tomcat-Installation

Tomcat installation

Step 3: You need to click on next button.

Agree Installation

Agree Installation

Step 4: Then agreed for installation.

Step 5: Then next -> next-> Finish.

Finish Installation

Finish Installation

Step 6: Now Your server is running on port “http://localhost/8080″.

http://localhost:8080

http://localhost:8080

Restart or Running of Tomact Server

If you want to stop the server then you need to go to the folder name “Program Files” like in my system “C:\Program Files\Apache Software Foundation” >> “C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin”.

Step 1: Then go inside bin folder

bintomcat

bin folder

Step 2: Right click on Tomcat9w and then click on stop and similar you can again re-start from here.

start-stop server

start-stop server

How to install Tomcat Server on Linux

Step 1: Install Java (if not already installed)

sudo apt update

Step 2: Install the default JDK (Java Development Kit)

sudo apt install default-jdk

Step 3: Verify the Java installation

java -version
Java (jdk) setupUp

JDK Installation

Setting up a Tomcat User

Step 1: Create a new user

sudo useradd -r -m -U -d /opt/tomcat -s /bin/false tomcat

Step 2: Downloading the Tomcat package

wget -c https://downloads.apache.org/tomcat/tomcat-9/v9.0.87/bin/apache-tomcat-9.0.87.tar.gz

Step 3: After the downloading extract the file

sudo tar xf apache-tomcat-9.0.87.tar.gz -C /opt/tomcat

Step 4: Change directory

cd  /opt/tomcat
ls -ls
Installation

Installation

Steps To Change The Bin Directory

Step 1: Change to root user

sudo su

Step 2: Change directory

cd /opt/tomcat/apache-tomcat-9.0.87/bin/

Tomcat Started

Step 3: Start Tomcat using either of the following commands

sh startup.sh
OR
./startup.sh

Step 4: Open browser, now server is running on

http://localhost:8080/
Server at localhost

Server at localhost

Step 5: For stop running server

./shutdown.sh
Stop Server

Stop Server

Advantages Of Apache Tomcat

  • Free and Open-Source.
  • Easy to Use and Install.
  • Supports Multiple Platforms: Tomcat runs on various operating systems, including Windows, Linux, and macOS.

Disadvantages Of Apache Tomcat

  • Slower Performance Under Heavy Load: When the server experiences high traffic, Tomcat’s performance may slow down.
  • Limited Technical Support: The availability of technical support for Tomcat is limited compared to commercial alternatives.

Applications

  • Web Hosting for Java Applications:
    • Tomcat is widely used for hosting Java-based applications on the web.
    • It implements the Java Servlet and JavaServer Pages (JSP) specifications.
  • Embedded Servers:
    • Tomcat can be embedded within other applications or services.
    • Developers often use it as an embedded servlet container for lightweight deployments.
  • Commonly used for enterprise applications involving:
    • Java Expression Language
    • Java Servlet
    • Java WebSockets
    • Java Server Pages2
  • Web Applications Deployment:
    • Each web application comprises resources such as HTML with Java code, Server Pages, Java Servlets, libraries, and other items required to execute the program.
    • These web applications are stored in Tomcat’s “webapps” directory as folders or WAR (Web Application Archive) files

Start Tomcat Server – FAQ’s

What is a connector in Apache Tomcat?

A connector in Apache Tomcat is a component that enables communication between the web server and clients, Handling incoming requests and sending responses. It bridges various protocols like HTTP.

How do I start my tomcat server?

To start your Tomcat server, navigate to the Tomcat installation directory and run the command ./bin/startup.sh.

How to run Tomcat server using Java?

You can run Tomcat server programmatically in Java by instantiating org.apache.catalina.startup.Tomcat and calling its start() method.

How do I restart Tomcat server in Linux?

You can restart the Tomcat server in Linux by running the command sudo systemctl restart tomcat. Alternatively, you can use service tomcat restart.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads