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

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

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.

Leave a comment

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

Current day month ye@r *