How to install Tomcat7 and Oracle Java on Ubuntu Debian

We assume that you have Ubuntu 12.04 installed (64bit recommended).

First we update default packages –

Once this is complete, we install Oracle Java 7. As this has been excluded from Ubuntu’s repositories, we need to add a new repository using the add-apt-repository command. To use this command, we first install –

To install Oracle Java 7 –

Ref: http://www.ubuntugeek.com/how-to-install-oracle-java-7-in-ubuntu-12-04.html

Debian user: check syntax in 

and choose the most recent stable version that you can find at the address  

, in my case is  

To make sure you have correctly installed it, run –

You should get the following (or similar) if everything has been installed –

Once Java is installed, let us install Tomcat 7. As Ubuntu 12.04 includes Tomcat 7 by default, no additional repository is required. Just run –

tomcat7-docs tomcat7-examples tomcat7-user tomcat7-admin are suggested packages but not necessary for installation / running of Tomcat 7.

After installation, Tomcat 7 will try to start but will fail due to following error –

This error tells us that JAVA_HOME is not set. To resolve this open the file

Add the following line and save the file. –

Now you can try starting Tomcat using the following command –

from http://leapswitch.com/blog/technical-solutions/how-to-install-tomcat7-oracle-java-apache-virtualhosts-ubuntu-12-04-lts/