Before you can run your FreeMarker webapp, you’ll need to start a server locally. This tutorial will go over a basic Apache Tomcat configuration for your local machine.
This tutorial assumes you have some basic knowledge of programming concepts and problem solving skills.
You will also need a computer with admin/root access.
This tutorial is simply a guide to get a server up and running for local development. This tutorial should by no means be used as a reference for setting up an enterprise webapp. This tutorial is not being written from the perspective of a security expert and should not be treated as such. Again: This information is only for the purpose of local development.
Alright. Now that we have that out of the way—let’s move on.
Many different servers will run JEE webapps and they all have their various pros and cons. I’ve found Tomcat easy to configure and I like how quickly it starts up. (I’m sure other web servers are also easy to configure and start up just as quickly.)
You are more than welcome to use another sever, such as JBoss or GlassFish, but all these tutorials will be referencing Tomcat paths.
At the time of this writing, the latest stable version of Tomcat is 8.0.26.
(Based on Windows 7)
Note: Make sure all your Command Prompt windows are closed before you start this tutorial.
-
On the Tomcat download page, under Binary Distributions > Core, download the either the 32-bit or 64-bit Windows zip. (If you aren’t sure if your system is 32-bit or 64-bit, download the 32-bit version.)
-
Extract the zip somewhere you’ll remember, like
C:\tools\apache-tomcat-8.0.26
(Make sure it’s notC:\tools\apache-tomcat-8.0.26\apache-tomcat-8.0.26
!!!): -
Open up environment variables (tutorial on how to access your environment variables) and set
CATALINA_HOME
equal to the place where you just extracted your zip file: -
Next we have to add
CATALINA_HOME
to our path. In environment variables, find the Path variable and edit it: -
At the end of “Variable value” add
;%CATALINA_HOME%\bin
(Don’t forget the semi-colon!) -
Click “OK” and “OK” again and “OK” one last time to exit out of environment variables.
-
Open up command prompt and type
echo %CATALINA_HOME% && where catalina
and you should see something like this:If you do not see this you may have had a command prompt open while editing your environment variables and you will need restart your computer and try again.
-
Open up Command prompt and type
catalina start
. You should see a console window open.
- (If you get an error like
'startup' is not recognized as an internal or external command
, log in and out and that should fix it) - Note: A notification from Windows firewall may pop up. It’s safe to allow access for private networks.
-
Open your favorite web browser and navigate to http://localhost:8080/. You should see something like this:
-
If you haven’t already done so, install Homebrew. Homebrew is similar to APT and facilitates easier package management.
-
Open up Terminal and install Tomcat with Homebrew:
brew update
brew install tomcat ```
-
Once installation is complete, in Terminal start up Tomcat by running
catalina start
-
Open your favorite web browser and navigate to http://localhost:8080/. You should see something like this:
Remember where you installed Tomcat! We will need to update the configuration in the next tutorial.
Continue to the next tutorial: FreeMarker “Hello World”