I have some older Java and Grails projects that need Grails 1.3.x and Java 1.5 on an Ubuntu 11.10 system that is already running Grails 2 and Java 6. Here are the steps I took to install the old Java 5 SDK and switch between the two.
Download the Java 1.5 SDK package from the Oracle site with past distributions. For Ubuntu running in a virtual machine, I used the i586.bin file. Run these commands to install the bin:
# sudo mv jdk-1_5_0_22-linux-i586.bin /usr/lib/jvm # cd /usr/lib/jvm # chmod +x jdk-1_5_0_22-linux-i586.bin # ./jdk-1_5_0_22-linux-i586.bin
Tell the update-alternatives command about the new version of Java that is available:
# sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.5.0_22/bin/java" 2 # sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.5.0_22/bin/javac" 2
You can switch between the installed versions of Java using the command:
# sudo update-alternatives --config java # sudo update-alternatives --config javac
Confirm the version of Java currently in use with these commands:
# java -version # javac -version
This post on Stackoverflow and on Ubuntu forums pointed me in the right direction along with the Oracle instructions for installing the JDK on Ubuntu and this Wikihow article.