Wednesday, October 01, 2008

How to install Sun Java Development Kit (JDK) & Java Runtime Environment (JRE) on Ubuntu Linux

- Run the following command in Terminal:

$ sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk

- Set the Sun Java as the default Java:

$ sudo update-java-alternatives -s java-6-sun

- Make the Sun JVM as the first searchable JVM

used and text editor to edit the file /etc/jvm. Make sure /usr/lib/jvm/java-6-sun is the first in the jvm list.

# 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.

/usr/lib/jvm/java-6-sun
/usr/lib/jvm/java-gcj
/usr/lib/jvm/ia32-java-1.5.0-sun
/usr/lib/jvm/java-1.5.0-sun
/usr

- Set JAVA_HOME and PATH

used and text editor to edit the file $HOME/.bash_profile

Append the line:

export JAVA_HOME=/usr/lib/jvm/java-6-sun
export PATH=$PATH:$JAVA_HOME/bin

- Now you can clarify you java version:

$ java -version

java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)

- That's.