[Solved] How to Install Tomcat5 and JDK5 on Ubuntu 20.04 LTS

[Solved] How to Install Tomcat5 and JDK5 on Ubuntu 20.04 LTS

Installation of Tomcat and JDK on Unbuntu is just issuing few commands and having a glass of coke. It will surely install the latest versions of both but what if someone is too lazy to upgrade its code and requirement Tomcat version. Legacy applications mostly do this when you need to migrate the infrastructure and but all what is available on the cloud is the newer version of the operating systems like Ubuntu 20.04 is available everywhere. I had to deal with one of my client’s requirement where I was given a task to install Tomcat5.5 and JDK5 so that a legacy application can run on it. I had to invest a good amount of time to find a single article where both these items were accomplished but was failed so I decided to write this article “[Solved] How to Install Tomcat5 and JDK5 on Ubuntu 20.04 LTS”.


Installation and configuration of JDK5

Things are not that complicated if you read the errors and follow general instructions to solve them. First I will provide the basic and simple steps to install JDK5.

  1. Visit the link below to download the JDK5 source so that it can be uploaded to the server for necessary configuration.
  2. Download link
  3. I download JDK 1.5.0_22 like given in below snap:
  4. JDK1.5.0.22











Install tar on Ubuntu 20.04 if its not already installed. Extract JDK in a directory, I would prefer to use under listed path:

sudo mkdir -p /usr/lib/jvm/java5
sudo tar xf java5.tar.gz -C /usr/lib/jvm/java5

Now we need to create alternate paths for all requirement JAVA applications:

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java5/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java5/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/java5/bin/javaws" 1

Now we need to correct the permissions of the newly created Alternates:

sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/lib/jvm/java5

Check if it successful which was not in my case

java -version

Error: bash: /usr/bin/java: No such file or directory


Mostly above commands and method is available on the internet which might not work and that was my case so I have to put extra efforts to resolve it. As the downloaded JDK is 32bit so we need to install some libraries to make it work otherwise we will get under listed error:

apt-get install libc6-i386

Once you are done with the above error, I received another error:

Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object

As we have downloaded .bin files, means binary so we need to do some manual work as well. The installer unpack few pack files while installation of JDK and convert them to .jar files but in our case it will not unpack as we manually untar the bin file. Now we need to unpack the rt.pack to rt.jar file. use the under given command to accomplish this task.

/usr/lib/jvm/java5/bin/unpack200 -r -v rt.pack rt.jar

Check if it successful, at least it successful in my case.

java -version

Now we need to set the JAVA_HOME. copy and paste under given command (if you have chosen the same path like above)

export JAVA_HOME=/usr/lib/jvm/java5

Installation and configuration of Tomcat5.5.9

Download Tomcat5.5.9 from under given link:

Download Tomcat5.5.9

Uncompress the tar file, use under given command:

tar xvfz jakarta-tomcat-5.5.9.tar.gz

I chose /usr/local/tomcat. Now we need to 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:

gedit ~/.bashrc

Add the following lines to the file:

#Stuff we added to make tomcat go
export JAVA_HOME=/usr/lib/jvm/java5
export CLASSPATH=/usr/local/tomcat/common/lib/jspapi.jar:/usr/local/tomcat/common/lib/servlet-api.jar

Tomcat should now be ready to run.

In terminal type:

sh /usr/local/tomcat/bin/startup.sh

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

Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:       /usr/lib/j2sdk1.5-sun/

In your browser head to http://localhost/ and test if it is serving.

To stop tomcat type:

sh /usr/local/tomcat/bin/shutdown.sh

1 thought on “[Solved] How to Install Tomcat5 and JDK5 on Ubuntu 20.04 LTS”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.