Checking if JAVA is already installed in your system

Follow this step to check if Java software development kit (JDK) is already installed in your system.
To determine if JAVA SDK is already installed in your system, run the following command from command prompt.

dpkg –get-selections | grep sun-java

This should give you this output if you already installed java:

sun-java6-bin                                   install
sun-java6-jdk                                   install
sun-java6-jre                                   install

Install JAVA SDK

If that command has no results or a previous version is installed, you’ll want to install the latest version with this command:

sudo apt-get install sun-java6-jdk

Set up the JAVA_HOME environment variable

Tomcat requires setting the JAVA_HOME variable. The best way to do this is to set it in your .bashrc file. The better method is editing your .bashrc file and adding the bolded line there. You’ll have to logout of the shell for the change to take effect.

vi ~/.bashrc

Add the following line:

export JAVA_HOME=/usr/lib/jvm/java-6-sun

Install Tomcat

Now we’ll download and extract Tomcat from the apache site. You should check to make sure there’s not another version and adjust accordingly.

tar xvzf apache-tomcat-6.0.14.tar.gz

The best thing to do is move the tomcat folder to a permanent location. I chose /usr/local/tomcat, but you could move it somewhere else if you wanted to.

sudo mv apache-tomcat-6.0.14 /usr/local/tomcat

Starting and shutting down Tomcat

To startup the tomcat server, run the file.

sudo /usr/local/tomcat/bin/

To shut down the tomcat server, run the file.


Verifying Tomcat installation

To verify that tomcat is installed properly, start the server as explained above, open the web browser and access the following URL.


You should see the default Tomcat welcome page as shown here.

ubuntuwel.png (231 KB) Nikos Simou, 06/03/2011 09:38 PM