Ubuntu repository does not provide the latest version of Apache Tomcat. If you are desired to install the latest version of Apache Tomcat and to add it to the Eclipse, this article is for you.
Step 1:
Step 2:
Step 3:
Step 4: (Optional)
Step 5:
Step 6:
Step 7:
Step 8:
Step 9:
Step 10:
Step 11:
Step 1:
Step 2:
Step 3:
Step 4:
Step 5:
Step 6:
Step 7:
Requirements:
ApacheTomcat depends on Java Development Kit so you must have either Oracle JDK or OpenJDK installed on your system. In case if you do not have JDK in your system, follow these articles first and install Oracle JDK on your computer.
Step 1:
Download the latest version of Apache Tomcat from the official link.
Step 2:
Open the Terminal (Ctrl + Alt + T) and enter the following command to change the directory.
cd /opt/
Step 3:
Enter the command given below to extract the Tomcat from the ~/Downloads directory. If your downloaded file is in any other directory, replace the last parameter by the actual file path.
sudo tar -xvzf ~/Downloads/apache-tomcat-8.5.50.tar.gz
Step 4: (Optional)
Rename the folder name to apache-tomcat.
sudo mv apache-tomcat-8.5.50/ apache-tomcat/
Step 5:
Tomcat creates some files at the runtime inside this folder (Log files and some other configuration files). If you want to start Tomcat without root privilege, it is required to change the permission of this directory. Enter the following command to change the permission of apache-tomcat folder.
sudo chmod -R 777 apache-tomcat/
Step 6:
An environment variable has to be added to the system. Enter the following command in the terminal to open the /etc/environment in gedit.
sudo gedit /etc/environment
Step 7:
Add the following line at the end of the file. Save and close the gedit.
CATALINA_HOME="/opt/apache-tomcat"
Step 8:
Reload the environment variables to the current terminal using this command.
source /etc/environment
Enter the following command to start the Tomcat server.
$CATALINA_HOME/bin/startup.sh
Step 10:
Visit to the following URL.
https://localhost:8080/If you get the Apache Tomcat home page, you have successfully installed the Apache Tomcat in your system.
Step 11:
To stop the Tomcat, enter the following command.
$CATALINA_HOME/bin/shutdown.sh
Integrate Tomcat with Eclipse
If you do not have the Eclipse, follow this link and install the Eclipse first.
Step 1:
Open the Eclipse.
Step 2:
Goto Windows → Preferences in the menu bar and select the Runtime Environments under the Server.
Step 3:
Click on the 'Add' button.
Step 4:
Select your Apache Tomcat version under the 'Apache' root and click 'Next'.
Step 5:
Browse and select the Tomcat installation directory.
Step 6:
Click on the 'Finish' button
Step 7:
Click on the 'OK' button to close the Preferences dialog.
Now you are ready to use Apache Tomcat from Eclipse.
16 comments
Write commentsThanks
ReplyYou are welcome Steven
ReplyHi Gobinath, Thanks for the tutorial. If I ask what happens to my apache install running on port 8080 when I install tomcat on the same port?
ReplyHi,
ReplyTwo processes cannot listen to the same port. I usually allocate port 80 for Apache and port 8080 for Tomcat. Depending on your preference change the port of either of them.
I am getting "Unknown version of Tomcat was specified." when I go to select the Tomcat installation directory.
ReplyHi,
ReplyI hope you have installed the Tomcat as given in this tutorial. Make sure that you are providing the parent folder of Tomcat and your Eclipse supports the specific Tomcat version.
I am using Tomcat 8.5.4, Spring Tool Suite Version: 3.8.0.RELEASE, Java 8, and Ubuntu 16.04. I am not sure how to check if I am using the right tomcat version.
ReplyThank you so much!!
ReplyIt helped me for installing tomcat v8.5 on ubuntu 16.04 for eclipse neon.
Searched alot of sites,none of them were useful.Thank you for the beautiful post.
Okay. My bad. I need first to stop oracle-xe service (using the same port as Tomcat). Thanks for helpful article!
ReplyHi
ReplyI installed Tomcat (as in the tutorial) but when I open localhost:8080/ browser displays login. How can I login?
Thank you so much. Really helpful.
Replyi am not getting option of server in my eclipse. Please help
ReplyHi,
ReplyDo you use the Eclipse IDE for Enterprise Java Developers? The Eclipse IDE for Java Developers may not have this option.
Hello i have follow all the steps of tutoriel but when i want i choose the version of tomcat éclipse said that:"tomcat requires an SDK environnement to compile JSP FILES...." please help
ReplySorry I made an assumption that Java is already installed. Please follow this link to install Oracle JDK and then add Tomcat to Eclipse. https://www.javahelps.com/2017/09/install-oracle-jdk-9-on-linux.html
ReplyThis worked. Thank you
ReplyEmoticonEmoticon