Java 5

Install SUN JDK5 on Ubuntu 20.04 64-bit

========================================================




0. References

------------------------

https://www.windowstechupdates.com/solved-how-to-install-tomcat5-and-jdk5-on-ubuntu-20-04-lts/



------------------------

1. Get the software

------------------------

http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase5-419410.html#jdk-1.5.0_22-oth-JPR

Donwload 'jdk-1_5_0_22-linux-amd64.bin' to temporary directory, eg: /tmp/jva5install/



------------------------

2. Unpack the .bin

------------------------

unzip jdk-1_5_0_22-linux-amd64.bin



------------------------

3. Move into something a little more Ubuntu appropiate.

------------------------

sudo mkdir -p /usr/lib/jvm/java-5-sun-1_5_0_22

sudo mv jdk1.5.0_22/* /usr/lib/jvm/java-5-sun-1_5_0_22/



------------------------

4. Follow the Ubuntu tradition, symlinking a generic major java version to a concrete minor version

------------------------

sudo rm /usr/lib/jvm/java-5-sun && sudo ln -s /usr/lib/jvm/java-5-sun-1_5_0_22 /usr/lib/jvm/java-5-sun



------------------------

5. Ubuntu Java Alternatives

------------------------

type this command and count the number of java version you have.

sudo update-alternatives --config java


Note: There were 5 alternatives in link group java (1 auto mode and 4 manual mode).


Once you have that number enter this command and change the number on the end of it to the number you just found plus one.

$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-5-sun/jre/bin/java 5


$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-5-sun/bin/javac 5

$ sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/java-5-sun/bin/javadoc 5

$ sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/java-5-sun/bin/javah 5

$ sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/java-5-sun/bin/javap 5




------------------------

6. Unpack rt.pack & tools.pack

------------------------

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.


$ cd /usr/lib/jvm/java-5-sun/jre/lib/ && sudo /usr/lib/jvm/java-5-sun/bin/unpack200 -r -v rt.pack rt.jar

$ cd /usr/lib/jvm/java-5-sun/lib/ && sudo /usr/lib/jvm/java-5-sun/bin/unpack200 -r -v tools.pack tools.jar



------------------------

9. Bash aliases for easily changing jdk versions

------------------------

$ gedit ~/.bash_aliases


# JDKs

alias jdk5='export JDK_HOME=/usr/lib/jvm/java-5-sun && export JAVA_HOME=$JDK_HOME && $JAVA_HOME/bin/java -version'



$ source ~/.bash_aliases



To make sure everything worked, run this command. It should output your version:

$ $JAVA_HOME/bin/java -version

java version "1.5.0_22"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)

Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_22-b03, mixed mode)