How do I install Sun Java Development Kit (JDK) and Java Runtime Environment (JRE) under Ubuntu Linux? It appears that there are multiple JRE installed by default under Ubuntu. How do I select and use Sun JRE only?
This is a tough question, yet here’s a simple answer, even for beginners.
Ubuntu Linux has following packages from Sun:
1. Open a shell prompt (terminal) and type the following to install JDK and JRE:
sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk
2. Ubuntu Linux comes with update-java-alternatives utility to updates all alternatives belonging to one runtime or development kit for the Java language.
sudo update-java-alternatives -s java-6-sun
if that doesn’t work, just skip to the next step (you might not have any other version installed).
3. You also need to edit a file called /etc/jvm. This file defines the default system JVM search order. Each JVM should list their JAVA_HOME compatible directory in this file. The default system JVM is the first one available from top to bottom. Open /etc/jvm
sudo vi /etc/jvm
I use mcedit, since vi is soooo out of this world!
4. Make sure /usr/lib/jvm/java-6-sun is added to the top of JVM list (or first):
5. You also need to setup JAVA_HOME and PATH variable. Open your $HOME/.bash_profile or /etc/profile (system wide) configuration. Open your .bash_profile file:
6. Append the following lines to the bash profile settings:
7. Now try to see if it worked: