Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apache Tomcat installation directory in ubuntu / configure Tomcat in eclipse + ubuntu

Tags:

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.

like image 647
Jisson Avatar asked Jun 27 '12 05:06

Jisson


People also ask

Where is Tomcat installation directory in Eclipse?

For configuring the tomcat server in eclipse IDE, click on servers tab at the bottom side of the IDE -> right click on blank area -> New -> Servers -> choose tomcat then its version -> next -> click on Browse button -> select the apache tomcat root folder previous to bin -> next -> addAll -> Finish.

Where is Tomcat installation directory?

The Tomcat configuration files, in XML format, are located in the " conf " sub-directory of your Tomcat installed directory, e.g. " c:\myWebProject\tomcat\conf " (for Windows) or " ~/myWebProject/tomcat/conf " (for macOS).

How do I know if apache tomcat is installed on Ubuntu?

A simple way to see if Tomcat is running is to check if there is a service listening on TCP port 8080 with the netstat command. This will, of course, only work if you are running Tomcat on the port you specify (its default port of 8080, for example) and not running any other service on that port.


2 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

like image 64
Chandra Sekhar Avatar answered Oct 06 '22 06:10

Chandra Sekhar


Actually you can use Tomcat from Ubuntu repository with Eclipse (at least with Kepler version). It just requires couple of additional steps.

  1. Open Eclipse. Press File ⇒ New ⇒ Other... ⇒ Servers ⇒ Server ⇒ Next > ⇒ Apache ⇒ Tomcat v7.0 Server
  2. Select Tomcat Installation Directory: /usr/share/tomcat7
  3. Click Finish, ignore error message, click Finish again
  4. 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/ 
  5. Concat policy files into one file:

    cd ~/workspace/Servers/Tomcat\ v7.0\ Server\ at\ localhost-config/ cat policy.d/* > catalina.policy 
  6. 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).

  7. Return to Eclipse, select 'Servers' in Project Explorer (left panel), press F5, to refresh it.
  8. 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.

like image 43
Dmitriy Sukharev Avatar answered Oct 06 '22 06:10

Dmitriy Sukharev