How to install Java 1.6 in Linux

On Debian platform, Sun's Java is available via the non-free repository. If you would like to install Java JRE or JDK on Debian Squeeze, do the following.

$ sudo vi /etc/apt/sources.list
deb http://ftp.us.debian.org/debian/ squeeze main non-free
$ sudo apt-get update

To install Java runtime environment:

$ sudo apt-get install sun-java6-jre

To install Java development environment:

$ sudo apt-get install sun-java6-jdk

Finally, set up JAVA_HOME environment variable as follows. Note that you need to replace the Java version number with your own.

$ sudo vi /etc/environment
JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.26
PATH=$JAVA_HOME/bin:$PATH

On CentOS platform, OpenJDK is available via RPMforge repository. If you would like to install Java JRE or JDK on 64-bit CentOS 6, do the following. For 32-bit CentOS 6, replace "x86_64" in the rpm file name with "i686".

$ cd /usr/local/src
$ sudo rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
$ sudo wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
$ sudo rpm -Uhv rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

To install Java runtime environment:

$ sudo yum install java-1.6.0-openjdk -y

To install Java development environment:

$ sudo yum install java-1.6.0-openjdk-devel -y

Finally, set up JAVA_HOME environment variable, according to your installation:

$ sudo vi /etc/profile.d/java.sh
export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64
export PATH=$JAVA_HOME/bin:$PATH

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

Leave a comment

Your email address will not be published. Required fields are marked *

Current ye@r *