Installing Tomcat 7 with OpenJDK on Tiny Core Linux

Pre-requisites for Installing Tomcat 7

Follow my earlier tutorials for installing Tiny Core Linux and Java,

This tutorial uses Tiny Core Linux 4.1 and OpenJDK6. However the steps are similar if you use Java 7 or Oracle binaries for Java.

Installing Tomcat 7 with OpenJDK on Tiny Core Linux

Go to Tomcat 7 download page and note down a mirror URL for the tomcat-7.0.22.tar.gz file. From the Tiny Core Linux terminal download the file using wget (depending on the mirror the URL may be different),

wget http://apache.petsads.us/tomcat/tomcat-7/v7.0.22/bin/apache-tomcat-7.0.22.tar.gz

downloading tomcat 7 tiny core linux

Since I have already configured /opt as a persistent folder in the hard drive, I decided to install tomcat in /opt. Copy the downloaded tomcat zip file to /opt.

mv apache-tomcat-7.0.22.tar.gz /opt

Extract the tomcat binaries using the tar command,

cd /opt

tar -xzf apache-tomcat-7.0.22.tar.gz

Now we have tomcat 7 installed in /opt/apache-tomcat-7.0.22. To start tomcat, change to the bin folder and invoke the startup script,

cd /opt/apache-tomcat-7.0.22/bin

./startup.sh

You can verify whether tomcat is running by accessing the default URL using wget,

wget http://localhost:8080

How to Start Tomcat on Tiny Core Linux Startup (Boot) ?

You can configure Tomcat to start automatically whenever Tiny Core Linux is booted. Any command added to /opt/bootlocal.sh in Tiny Core Linux is invoked during system startup. Add the following lines to bootlocal.sh to start Tomcat on system startup,

export CATALINA_HOME=/opt/apache-tomcat-7.0.22
export JAVA_HOME=/usr/local/openjdk-6
/opt/apache-tomcat-7.0.22/bin/startup.sh

Note that the environment variables are required since they may not be set properly when bootlocal.sh commands are invoked.

When Tiny Core Linux was installed with Tomcat 7 and OpenJDK on VirtualBox, the size of the virtual disk created was under 150MB. So this combination is an ideal portable OS for testing your Java web applications on Linux!

Installing Java in Tiny Core Linux

When it comes to installing Java in Tiny Core Linux, there are two options. You can either install the open source implementation of Java(OpenJDK) or install the official Java binary from Oracle. In this article I will show how to install any of these Java flavors in your Tiny Core Linux installation. For the example below I use Tiny Core Linux 4.1 and Java 1.6. The steps are similar for other versions.

Click here for the detailed tutorial on installing Tiny Core Linux in a hard disk. This tutorial also sets the hard disk partition as the location for downloaded extensions. Please note that for Oracle Java installation, hard disk partition requires over 500MB of free space.

Installing OpenJDK in Tiny Core Linux

Installing OpenJDK 6 in Tiny Core Linux is easy since OpenJDK is part of the Tiny Core Linux extension repository. From the bottom menu bar, click on AppBrowser. This opens up the extension manager for Tiny Core Linux.

Installing extensions in Tiny Core Linux

Click on connect and then search for openjdk. Select openjdk-6-jdk.tcz and then click on the Go button on bottom left. It will take a while to install openjdk since the download size of the package is around 55MB. Note the location of the downloaded extension (/mnt/sda1/tce/optional). It points to the partition assigned for the tce boot code.

Installing OpenJDK in Tiny Core Linux

Restart Tiny Core Linux and run the following command to verify that Java is installed on TCL,

java -version

Finding Java Version

 

Installing Oracle Java 6 in Tiny Core Linux

Some people prefer to install Oracle Java since it is usually more stable and well tested with Java programs than OpenJDK. Also some of the applications only work with Oracle JDK.

Download Oracle Java binary file using wget command (from the home folder),

wget http://download.oracle.com/otn-pub/java/jdk/6u29-b11/jdk-6u29-linux-i586.bin

Now you may be wondering how I got the URL for the Java binary. Visit Oracle JDK download site and then click on download link for JDK 6. Accept the license agreement on the next page and then right click and copy the URL for the Linux x86.

Change the type of the downloaded file to an executable file,

chmod +x jdk-6u29-linux-i586.bin

Now extract the contents of the binary by running the binary file,

./jdk-6u29-linux-i586.bin

The Java files are extracted to the folder jdk1.6.0_29. During Tiny Core Linux installation, we had configured /opt and /home as persistent folders. Hence we will copy the JDK to /opt folder.

Create java folder,

cd /opt

mkdir /java

Go back to home folder and then move the JDK files extracted earlier to /opt/java,

cd

mv jdk1.6.0_29 /opt/java/

You can set the JAVA_HOME and path to Java binary permanently in the .ashrc file in the home folder (/home/tc),

cd

vi .ashrc

Add the following content to .ashrc,

export JAVA_HOME=/opt/java/jdk1.6.0_29
export PATH=$PATH:$JAVA_HOME/bin

Restart Tiny Core Linux. Run the following command to verify that Oracle Java is installed correctly on Tiny Core Linux.

java -version

Oracle Java in Tiny Core Linux

Mouse Cursor Problem – Tiny Core Linux in VirtualBox

I recently came across a nasty mouse cursor problem when running Tiny Core Linux in VirtualBox. I use VirtualBox 4.1.6 with VirtualBox extensions pack for running Tiny Core Linux. After installing Tiny Core Linux, VirtualBox provided seamless integration of mouse cursor. Whenever I move cursor over Tiny Core Linux window, the mouse control was automatically handed over to TCL.

However the behavior of the mouse cursor was erratic when in Tiny Core Linux. Sometimes you could only navigate half of the Tiny Core Linux window and then control gets handed over to the host machine (Windows 7 in my case). It is a nasty bug and it almost makes TCL completely unusable in VirtualBox.

This problem seems to be caused by a bug in VirtualBox. However there is a quick work around to fix this problem. Open Settings => System => Motherboard page of the TCL virtual machine from VirtualBox. Uncheck the "Enable absolute pointing device" option from the screen as shown below,

fixing mouse cursor problem in Tiny Core Linux with VirtualBox

There is a downside to this fix. The seamless mode no longer works and hence you need to press the host button (default is right control) to change the mouse cursor control from host to guest OS and vice versa.

This seems to be a problem with VirtualBox 4.x series installations. Please note that I don’t have VirtualBox guest extensions installed and I don’t know whether it will solve the issue.

Next Page »