For Java 5:
sudo apt-get install sun-java5-jre sun-java5-jdk
For Java 6:
sudo apt-get install sun-java6-jre sun-java6-jdk
There are other packages that you might be interested in:
- sun-java6-demo
- sun-java6-doc
- sun-java6-source
Verify that you have the correct version of java running:
java -version
To see a list of the java versions that you have installed, you can use the following command (it’s a letter L at the end of the command):
update-java-alternatives -l
This should show you a list of all the java alternatives you have installed. java-gcj is the free version of Java from the GNU project and comes installed by default with Ubuntu so you should see it. To switch to a different version, use the following command:
sudo update-java-alternatives -s <version-desired>
e.g:
sudo update-java-alternatives -s java-1.5.0-sun