How should I install Apache Tomcat 7 for use with Eclipse?
You can use sudo apt-get install tomcat7
to install Tomcat.
To disable autostarting, run the following command after installing:
sudo update-rc.d tomcat7 disable
Here's the way I did it, it keeps the system tomcat and your own personal tomcat instance separate.
Install tomcat as per normal: sudo apt-get install tomcat7
Install private instance support: sudo apt-get install tomcat7-user
Create local instance in your home folder:
tomcat7-instance-create -p 10080 -c 10005 mytomcat
Note: -p sets the port number (default is 8080) and -c is the control port (default 8005), we set these so we don't compete with the main installation of tomcat running as a service. "mytomcat" can be anything you like, but it will create a directory by this name in your home.
Now use the following to make Eclipse happy:
cd mytomcat
ln -s /usr/share/tomcat7/lib
ln -s /etc/tomcat7/policy.d/03catalina.policy conf/catalina.policy
ln -s /usr/share/tomcat7/bin/bootstrap.jar bin/bootstrap.jar
ln -s /usr/share/tomcat7/bin/tomcat-juli.jar bin/tomcat-juli.jar
mkdir -p common/classes;
mkdir -p server/classes;
mkdir -p shared/classes;
Now within Eclipse you can create a Tomcat v7.0 server and set the installation directory as ~/mytomcat.
Note: common, server and shared classes could be links too, but I wanted to keep the two separate.
Note: Working perfect for me with Ubuntu 14.04 LTS & Eclipse Luna.
Use sudo apt-get install tomcat7
to install Tomcat7. Make sure you install tomcat7-admin too using sudo apt-get install tomcat7-admin
Run the command below to check the same.
whereis tomcat7
And before you add a server in Eclipse ensure to run the following commands, the tomcat server in eclipse expects to have these files and folders in their respective locations for working correctly.
cd /usr/share/tomcat7
sudo ln -s /var/lib/tomcat7/conf conf
sudo ln -s /etc/tomcat7/policy.d/03catalina.policy conf/catalina.policy
sudo ln -s /var/log/tomcat7 log
sudo chmod -R 777 /usr/share/tomcat7/conf
sudo ln -s /var/lib/tomcat7/common common
sudo ln -s /var/lib/tomcat7/server server
sudo ln -s /var/lib/tomcat7/shared shared
If you are going to solely use Eclipse to start and stop tomcat server then remove the tomcat7 from the startup script to disable it from starting automatically everytime the machine boots up.
sudo service tomcat7 stop
sudo update-rc.d tomcat7 disable
Now open the Java EE perspective in your Eclipse. Choose New server either from the File-> New menu or from New Server tab. In next screen, use /usr/share/tomcat7 as the tomcat installation directory or browse if you want to chose another custom installtion directory of tomcat7 and click finish.
References
- Joe's answer : Eclipse- cannot create server using selected type in tomcat7
2 - http://www.ajopaul.com/2015/06/23/setup-tomcat7-as-server-in-eclipse-luna-under-ubuntu-linux/