In this article i will show you how to correctly install Tomcat 9.0 which is the newest version of it. If you want to install and run it, you need to download and install jdk 8.0 first. Because it only run on jdk 8 or later. Please refer to following page to see the requirement before install.
Click here to download jdk 8 according to your operating system.
Start From Command-Line
Many web application developers like to run Tomcat from command-line, in most cases they just run it from eclipse they used. Following is the steps to achieve this.
1. Click here to download the zip file.
2.Unzip the zip file into a local folder like C:\WorkSpace\dev2qa.com\Tool\apache-tomcat-9.0.0.M21.
3.Edit conf\web.xml file under your installation directory. It is C:\WorkSpace\dev2qa.com\Tool\apache-tomcat-9.0.0.M21\conf\web.xml in my local windows machine. Search text org.apache.jasper.servlet.JspServlet in web.xml file and add following 2 initial parameters in it like below.
Tomcat will compile JSP files with language features provided by Java SE 8 after add these new servlet init parameters.
4.Before you can start it up, you need to set JAVA_HOME system environment variable’s value to the jdk 8 ‘s home you just installed. Please click this link to find how to set JAVA_HOME in windows and Linux. Following is just a picture for setting JAVA_HOME environment variable in windows.
5.After setting JAVA_HOME environment variable, you need restart your dos window or shell window to make the settings take effect. Then you can start it up use startup.bat or startup.sh command in it’s bin folder.
Open a shell window in Linux or a dos window in windows. Type following command to change current directory to your tomcat bin directory.
Type startup.bat in windows or startup.sh in Linux and click Enter key. Then Java console window popup and displaying the log information generated by Tomcat process. When you see the message like “Server startup in 1000 ms” in java console, that means it has been started successfully and is ready to process client request.
6. Put url http://localhost:8080/ in your favorite web browser’s url address input box and click Enter key. Then you will see below page, if not then your Tomcat may not start correctly, you need to review previous steps carefully.
Install as windows service
Install and run Tomcat as windows service is commonly used in production and quality assurance environment.
Advantages of windows service
- Server startup do not need active administrator login.
- Automatically startup when your server restart. This is very useful because in many cases you may need to restart your windows server. With this feature you do not need to login to your windows to start it again after os restart. Because as a windows service it will start automatically when os started.
- It is more secure when run it under a specific system account than administrator account.
Steps to install as windows service
- Download Tomcat windows installer file.
- Click the installer to install use default settings step by step.
- When you click Finish button at the last screen. It will popup a progress bar to tell you that it just installing windows services.
- After installation, you can find following menu in the system startup menu.
- When you click above menu, a dialog popup, we can use this dialog to configure a lot of settings of it.
- You can configure to start it manually or automatically when windows start. You can also stop, pause, restart it by clicking different buttons.
Different between Tomcat9.exe and Tomcat9w.exe
There are two wrapper program in it’s bin directory.
Tomcat9.exe is the wrapper program that make it run as a windows service at the background. We can see this from below picture.
You can run it with a a lot of input parameters. You can find all the parameters description and how to use them by click here.
Tomcat9w.exe is just the wrapper program which will popup the tomcat configure panel. You can do a lot of configuration in that panel.
You can also leave comments in this article. Our expert will response to you asap.