To develop JSPs or servlets, you need a Tomcat container and the latest JDK (Java Development Kit) to be installed on your local computer.
To find out if the JDK is already installed on your computer, you can open a command prompt window (CMD) or a terminal on macOS and run:
$ java -version
java version “12.0.2” 2019-07-16
Java(TM) SE Runtime Environment (build 12.0.2+10)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)
This output means you have JDK 12.0.2 installed on your computer.
Visit https://tomcat.apache.org/ and search for Binary Distributions
Download the .zip file if you are running Windows or tar.gz for macOS , and unzip the files on your computer wherever you want.
At the moment the most important files in our installation folder are:
tomcat/conf/server.xml
tomcat/conf/web.xml
tomcat/webapps
Proceed to set the CATALINA_HOME variable:
On windows open a a command prompt and type following command:
set CATALINA_HOME= ” C:\Users/gunther/Desktop/JavaProjects/Tomcat”
You can also go to environment variables and add a new variable called CATALINA_HOME
On macOS open a terminal and enter the following:
export CATALINA_HOME=”/Users/gunther/Desktop/JavaProjects/Tomcat”
You can also type: open ~/.bash_profile
And add
export CATALINA_HOME=”/Users/gunther/Desktop/JavaProjects/Tomcat”
in the .bash_profile file
Start the Tomcat container.
On Windows open a command prompt and type:
cd tomcat\bin
catalina.bat start
on macOS
cd tomcat/bin
./catalina.sh start
And finally open a browser and call:
