I decided to install Tomcat on my Pi and see what the performance is like.

 

First thing to do is make sure I have got the latest version of all my currently installed function - e.g. use command

 

sudo apt-get update



 

Step 1 - Install Java

 

Java installation is very straightforward with the following command

 

sudo apt-get install oracle-java7-jdk



 

Once that has finished you can check that Java installed correctly  with the command java -version. You should get something like this

 

java_blog_1.png

 

To double check that it was installed I wrote and compiled a simple java class - of course it had to be "HelloWorld".

 

Using the 'nano' editor, I created a file called HelloWorld.java which contains the following ;

 

public class HelloWorld {
     public static void main(String args[]) {
          System.out.println("Hello World !!");
     }
}



 

I compiled this with the command javac HelloWorld.java which created class file HelloWorld.class.

 

Finally I executed the class using command java Helloworld and saw the expected output - i.e.

 

java_blog_2.png

 

Step 2 - install Tomcat


Download Distribution


Get the Tomcat distributions and unzip it as follows

 

wget http://mirrors.axint.net/apache/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42.tar.gz
tar xzf apache-tomcat-7.0.42.tar.gz

 

This will unpack the distribution underneath your current location (e.g. /home/pi/apache-tomcat-7.0.42)

 

Configure user

 

Before we start tomcat we need to configure an administrator user. Edit file tomcat-users.xml in the conf subdirectory (e.g. sudo nano conf/tomcat-users.xml) and add an entry under <tomcat-user>

 

e.g. add <user username="system" password="raspberry" roles="manager-gui"/>

 

java_blog_3.png

 

Start up

 

To start up Tmcat run startup.sh in the bin sub-directory - e.g. sudo bin/startup.sh

A small informational message will display and then the console will free up . Tomcat is now running in the background - to check this enter ps -ef | grep java and you should see something similar to the following;

 

java_blog_4.png

 

The best test of course is to try it in a browser - open a browser (which can be on another machine on your network) and enter URL e.g. 10.13.36.255:8080  (i.e. <server_name>:8080) and you should see something like this:

 

java_blog_5.png