GeeCON Prague 2014*
The moose likes Linux / UNIX and the fly likes How to install tomcat5 in Ubuntu 11.04 when it is not in the apt-cache? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "How to install tomcat5 in Ubuntu 11.04 when it is not in the apt-cache?" Watch "How to install tomcat5 in Ubuntu 11.04 when it is not in the apt-cache?" New topic
Author

How to install tomcat5 in Ubuntu 11.04 when it is not in the apt-cache?

Varuna Seneviratna
Ranch Hand

Joined: Jan 15, 2007
Posts: 167
I am new to Linux.I refereed the below extract which is at How to Install tomcat5

Installing Tomcat on Ubuntu

Versions:
SDK: 1.5
JRE: 1.5
Tomcat: 5.5

Step 1 – Install JRE and SDK

Download and install the Java Software Development Kit (SDK) and J2SE Runtime Environment (JRE). These packages are available through Synaptic (the extra repositories have to be added).

Or in terminal type:

N.B. SDK is 146MB and JRE is 84.7MB.

You can verify that both items were installed corectly, by checking that you get a response when typing in terminal:

Step 2 – Get tomcat

Download tomcat 5.5 from http://jakarta.apache.org/site/downloads/

In this example I am using jakarta-tomcat-5.5.9.tar.gz

Uncompress the file:

N.B. To make things simpler I also renamed the package to just 'tomcat'. If you do not do this, make sure you adjust these tutorial instructions to the name of your package whenever you see 'tomcat' written.

Step 3 – Add tomcat

Place the uncompressed package in:

/usr/local/

Step 4 – Set JAVA_HOME and CLASSPATH

You need to point out where you installed Java SDK. You will have to edit the file '.bashrc'. Backup this file first!

In terminal type:

Add the following lines to the file:

N.B. remember to change the word tomcat to the name of the package you placed in /usr/local.

Save and close. You will have to log out and back in again before these changes take effect.


The next steps are optional. They are for setting tomcat up to be used as a development environment. Skip to the last step ( Step 8 ) if you just want to start tomcat how it is.


Step 5 – Change default port number

Tomcats default port number is 8080. To change it to 80 or another number do the following.

In terminal type:

Find the lines:

Adjust the port number to 80 (or any other port number you want to use), save and close.

Step 6 – Turn on Servlet reloading

In terminal type:

Find:

Change it to:

Save and close.

Step 7 – Enable Invoker Servlet

In terminal type:

Find and uncomment (remove the <-- and --> wrapped around the tags):
Also find and uncomment:

Save and close.

Step 8 – Start tomcat

Tomcat should now be ready to run.

In terminal type:

If everything is working fine, you will see the following lines:

In your browser head to http://localhost/ and test if it is serving. If you didn't change the port number it was serving on, head to http://localhost:8080/

To stop tomcat type:

-----

I hope this helped!

If you have any problems, I recommend this site for more details: http://www.coreservlets.com/




I went through all the above up to the point where it says
Step 3 – Add tomcat

Place the uncompressed package in:

/usr/local/


I am not able to move the Uncompressed package in to the /usr/local/ directory by coping or cut and pasting.
Please advice on
How tomcat 5 should be installed and Is there a better way than the above?
How to move tomcat5 Uncompressed package in to the /usr/local/ directory or is there a better location than this
What is the default setting of privileges and permissions regarding file access in a Linux system
There is no tocmcat5 in apt-cache in such a situation what is the normally used way of installing?


Varuna Seneviratna
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11465
    
  94

Varuna Seneviratna wrote:How tomcat 5 should be installed and Is there a better way than the above?

The way mentioned above sounds perfectly reasonable to me.

Varuna Seneviratna wrote:How to move tomcat5 Uncompressed package in to the /usr/local/ directory or is there a better location than this

Personally I tend to use /opt for any packages I install that are not in a package management system. But that is just personal preference. Others have different views. If you are truly interested, you may wish to read such discussions as Point/Counterpoint - /opt vs. /usr/local.

Technically speaking, you do not need to move it to a "common" location unless there are multiple people using it. You can run Tomcat from within your home directory if you wished. I have a personal preference to move it, but it is certainly not mandatory.

As for how to move it - from the instructions you provided, you should have already been at the command prompt so you could issue the tar command. At this point, depending on the permissions of the /usr/local directory, you could:
  • mv jakarta-tomcat-5.5.9 /usr/local (if you have write access to /usr/local)
  • sudo mv jakarta-tomcat-5.5.9 /usr/local (if you do not have write access to /usr/local)

  • Side note: if you have to use sudo to move the Tomcat directory, you may wish to think about how you are running Tomcat. If you start Tomcat using your own user account, it will create the working and log directories with permissions for you to write to them, but probably nobody else. You may wish to verify that at least the group permissions are set correctly so that other users of your computer who are in the same group can also start it. Or set up a specific user/group to always start Tomcat as a daemon service. Or get your system administrator to set it up.

    Varuna Seneviratna wrote:What is the default setting of privileges and permissions regarding file access in a Linux system

    Your question is far too vague. The default settings for your home directory are probably different to the default setting for your Documents directory which will be different again to the default settings for the /usr directory which may still be different to the default settings for /usr/local

    Varuna Seneviratna wrote:There is no tocmcat5 in apt-cache in such a situation what is the normally used way of installing?

    Usually the same steps are followed as per the instructions you copied and pasted. Sometimes there are additional steps. Sometimes there are fewer steps. But the basic concept is typically the same.


    The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
    Varuna Seneviratna
    Ranch Hand

    Joined: Jan 15, 2007
    Posts: 167
    Since CLASSPATH is set to normal Java Programming can not be done.The java JRE is not able to find the class.An exception is generated



    How do I set tomcat in the way that it will not stand in the way of Java Programming and also be able to do Servlet and & JSP Programming
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander

    Joined: Mar 28, 2003
    Posts: 11465
        
      94

    Most people do not set the classpath anymore - try not setting it and confirm that tomcat starts up correctly. If it is unable to determine paths by itself, then you can set CATALINA_HOME to the location where you installed tomcat (/usr/local/tomcat) and it will determine the location of the directories based on that.
    Tim Holloway
    Saloon Keeper

    Joined: Jun 25, 2001
    Posts: 16101
        
      21

    Andrew Monkhouse wrote:Most people do not set the classpath anymore - try not setting it and confirm that tomcat starts up correctly. If it is unable to determine paths by itself, then you can set CATALINA_HOME to the location where you installed tomcat (/usr/local/tomcat) and it will determine the location of the directories based on that.


    Tomcat will determine which JDK to run under from the current OS environment, if it can. You can be more specific by setting the JRE_HOME environment variable, either in the sequence commands that you use to launch Tomcat or by adding a "TOMCAT_HOME/bin/setenv.sh" script that does the assignment.

    Tomcat actually runs with multiple classpaths, and which one is used depends on where in the Tomcat system you're working. The actual startup of Tomcat only requires the defaults of the JDK that Tomcat was launched under. Tomcat itself will build the other classpaths where/as needed. For example, when a WAR is deployed, Tomcat builds a classpath that includes the base JDK classes, all the jar files in the CATALINA_HOME directory, all the jar files in the webapp-s WEB-INF/WAR directory, and the WEB-INF/classes directory. So as you can see, each webapp would be provided its very own unique classpath.

    In the case of the servlet-api and jsp-api jars, they'd integrate in via the CATALINA_HOME/lib part of the classpath, so that means that you should not include them explicitly in the WAR, nor do you need to explicitly pull them in in any other way (and if you try, it will come back and bite you!).

    Of course, while the servlet-api and jsp-api jars may not be something that you'd actually include IN a WAR, they define interfaces such as HTTPServletRequest that are required to BUILD a WAR. So those 2 classes should be explicitly provided to the application compiler classpath. Just not to the runtime classpath.


    Customer surveys are for companies who didn't pay proper attention to begin with.
    pramod talekar
    Ranch Hand

    Joined: Apr 26, 2010
    Posts: 321

    Hello,

    I'm completely new to Ubuntu &/Linux, have installed it yesterday after my hard disk having windows 7 crashed and needed to be replaced.

    I followed this post for setting tomcat up. When I use the command prompt, and run Java -version, it shows me :-

    java version "1.6.0_23"
    OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10)
    OpenJDK Server VM (build 20.0-b11, mixed mode)

    As per this post, I entered the following path in the said file.

    #Stuff we added to make tomcat go
    export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/
    export CLASSPATH=/usr/local/apache-tomcat-6.0.33/lib/jsp-api.jar:/usr/local/apache-tomcat-6.0.33/lib/servlet-api.jar

    I tested it and got the following result:-


    pramod@pramod-Inspiron-1440:~$ sh /usr/local/apache-tomcat-6.0.33/bin/startup.shUsing CATALINA_BASE: /usr/local/apache-tomcat-6.0.33
    Using CATALINA_HOME: /usr/local/apache-tomcat-6.0.33
    Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.33/temp
    Using JRE_HOME: /usr/lib/jvm/java-6-openjdk/
    Using CLASSPATH: /usr/local/apache-tomcat-6.0.33/bin/bootstrap.jar

    Is this right? The post mentions about java 2sdk 1.5 but I've entered Openjdk details and still when I check with java -version , it shows me 1.6.23 and some openjdk details. Is it right?
    Is there any difference between Open jdk & sun jdk ?


    Thanks,
    Pramod
     
    GeeCON Prague 2014
     
    subject: How to install tomcat5 in Ubuntu 11.04 when it is not in the apt-cache?