I installed java7 and ApacheTomcat7 in my Ubuntu12.04, and download eclipse EE. And now I have to configure my eclipse with tomcat. For I want to find the tomcat installation directory. How can I find it. I installed java and tomcat using Ubuntu software centre.
-
@ ShaggyInjun , I installed using ubuntu software centre – Jisson Jun 27 '12 at 05:04
-
k, When you install tomcat using software center, it will install it according to Unix directory structure. I am not sure if eclipse honours that structure. Download tar.gz file from apache and unzip it in your home directory. This way you'll be able to configure tomcat in eclipse. – ShaggyInjun Jun 27 '12 at 05:05
-
this covers tomcat6 not 7 but same principle http://stackoverflow.com/questions/1356616/configuring-tomcat-6-with-eclipse-in-ubuntu hope this is what you wanted – Sean F Jun 27 '12 at 05:06
-
Answer you need (already linked to this question): http://stackoverflow.com/a/1446684/273689 – Frankovskyi Bogdan Oct 31 '12 at 19:07
5 Answers
1. Download the package "apache-tomcat-7.0.6.tar.gz
" from the below link
http://tomcat.apache.org/download-70.cgi [tar.gz]
2. Now unpack it with the following command:
tar xvzf apache-tomcat-7.0.8.tar.gz
3. Then move to more appropriate directory, in our case in /usr/share/tomcat7
, but can be in any directory. We do this with the command:
sudo mv apache-tomcat-7.0.8/ /usr/share/tomcat7
4. Now define the environment variables JAVA_HOME
and JRE_HOME
. This file is in the "environment" in / etc. Command to edit the file:
sudo gedit /etc/environment
5. Here we record the routes where we have installed Java in my case this is as follows:
JAVA_HOME="/usr/local/jdk1.6.0_23"
JRE_HOME="/usr/local/jdk1.6.0_23/jre"
PATH="...(other path):$JAVA_HOME:$JRE_HOME"
6. IMPORTANT: Verify the routes where they have installed Java.
sometimes tomcat does not recognize, but a surefire way of recognizing that tomcat is to define the file paths inside "catalina.sh
" located in tomcat7/bin
. To modify this file use the command:
sudo gedit /usr/share/tomcat7/bin/catalina.sh
Now insert the JAVA_HOME
and JRE_HOME
after the first line, so the file is as follows:
#!/bin/sh
JAVA_HOME="/usr/local/jdk1.6.0_23"
JRE_HOME="/usr/local/jdk1.6.0_23/jre"
# Licensed to the Apache Software Foundation (ASF)...
#...
#...
....
Now configure Tomcat users, this is done in the file "tomcat-users.xml
" directory tomcat7/conf
. Command to edit the file:
sudo gedit /usr/share/tomcat7/conf/tomcat-users.xml
7. Unlike previous versions, the administrator should own role "manager" now it should be "manager-gui
"to operate on the web administration tomcat7. The file would be as follows:
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="admin"/>
<user username="usuario" password="contrasena" roles="manager-gui,admin-gui,manager,admin,manager-script,admin-script"/>
</tomcat-users>
8. For further info look here
set-up-eclipse-and-tomcat-7-on-ubuntu-12-04
cannot-create-a-server-using-the-selected-type-eclipse-tomcat

- 16,256
- 10
- 67
- 90
-
7"Reinstall tomcat to the one folder" is not an answer to the main question. It's just a oblivious workaround "how to make your own tomcat install directory". – Frankovskyi Bogdan Oct 31 '12 at 19:01
-
1@FrankovskyiBogdan, If you really know anything about installation/ installation Issue for the above question, you could answer in better way, else you can improve the answer (given by me) to a generic way. Thanks for your comment. – Chandra Sekhar Nov 02 '12 at 04:36
-
-
6-1: While the procedures may work, almost every step violates good housekeeping guidelines: It mixes an install from repository with a downloaded one (`/usr/share/tomcat7`), hardcode java paths in `/etc/environment` and gives way too much roles in `tomcat_users.xml` (some of them outdated) – MestreLion Sep 04 '13 at 07:55
-
We have better solution for giving paths 1. In **.bashrc** file (User level access). 2. In **setenv.sh** file which must be created inside **tomcat/bin/** directory (tomcat level access). – Ajeesh Dec 09 '13 at 08:05
Actually you can use Tomcat from Ubuntu repository with Eclipse (at least with Kepler version). It just requires couple of additional steps.
- Open Eclipse. Press File ⇒ New ⇒ Other... ⇒ Servers ⇒ Server ⇒ Next > ⇒ Apache ⇒ Tomcat v7.0 Server
- Select Tomcat Installation Directory: /usr/share/tomcat7
- Click Finish, ignore error message, click Finish again
Copy Tomcat configuration to workspace executing from terminal:
sudo cp -r /etc/tomcat7/* ~/workspace/Servers/Tomcat\ v7.0\ Server\ at\ localhost-config/ sudo chown -R $USER:$USER ~/workspace/Servers/Tomcat\ v7.0\ Server\ at\ localhost-config/
Concat policy files into one file:
cd ~/workspace/Servers/Tomcat\ v7.0\ Server\ at\ localhost-config/ cat policy.d/* > catalina.policy
Either shutdown tomcat7 service every time before running it from Eclipse, or edit tomcat's ports in config files of your workspace (I suggest editing configs):
gedit ~/workspace/Servers/Tomcat\ v7.0\ Server\ at\ localhost-config/server.xml
You are interested in changing ports 8080, 8009 and 8005 (to, say, 9090, 9009 and 9005).
- Return to Eclipse, select 'Servers' in Project Explorer (left panel), press F5, to refresh it.
- Start Tomcat from Eclipse (see Servers tab in the bottom panel of Eclipse).
I wrote this answer based on my article. It's a bit more detailed, so refer to it if necessary.

- 1,084
- 2
- 11
- 20
You can install tomcat from repository.
search for tomcat.
sudo apt-cache search tomcat
Install tomcat admin and tomcat
sudo apt-get install tomcat7-admin sudo apt-get install tomcat7
Check for tomcat status
sudo service tomcat7 status
Start and stop tomcat
sudo service tomcat7 start sudo service tomcat7 stop
Bin folder for tomcat7 is at /usr/share/tomcat7 and logs and config are are at /usr/lib/tomcat7
Source: http://www.allaboutjava.club/linux/linux-install-tomcat7-on-ubuntu

- 69
- 5
-
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/11216989) – Fabio Lamanna Feb 10 '16 at 15:43
-
Point noted. Edited the answer. @FabioLamanna : thank you for the feedback – Karthik Arun Feb 10 '16 at 15:58
I like to use packages from the repository every time possible.
In this case:
sudo apt-get install tomcat7-user
sudo tomcat7-instance-create /srv/tomcats/ubuntu
sudo ln -s /usr/share/tomcat7/lib /srv/tomcats/ubuntu/
For tomcat6 the ln step can be skipped.
Then just use this path to add a tomcat7 server on eclipse. Tested on 14.04 and eclipse kepler sr2. Should work on 12.04.

- 211
- 2
- 2
Don't use by default command, like sudo apt-get install tomcat7
.
If you follow the above command then you will face lots of problem because CATALINA_HOME
and CATALINA_BASE
will be in different locations. In that case you have to declare environment variable separately.

- 14,489
- 8
- 42
- 72
-
2Note that such problems are Eclipse's fault, not Tomcat's (or Ubuntu repository): Eclipse is unable to handle `CATALINA_HOME` and `CATALINA_BASE` being distinct paths. It expects both to be the same, while it should not assume so. – MestreLion Sep 04 '13 at 07:49
-
1And the solution to this problem is to create a "/usr/share/tomcat" directory with symbolic links to the "different places". Many distros do this for you automatically; it's easy to do manually or with a shell script: [Configuring Tomcat in Eclipse](http://stackoverflow.com/questions/1356616/configuring-tomcat-6-with-eclipse-in-ubuntu) – paulsm4 Oct 05 '14 at 03:06